Currently I am working on a ROR code which uses rails paperclip gem.
My requirement is, to process images as per its file extension.
Case 1: If image type is “svg”, then do not process original image(as
ImageMagick breaks on resizing svg images). Upload original image, along
with large, medium, grayscale, grayscale_small versions. However all files
will be similar to original file, with different file names. Now I am able
to upload only original.svg file. However other versions are not created
correctly, and I did not find any solution so far.
Case 2: If it is not a “svg” image, then process image as per given style.
This is working as expected.
Current code looks like:
has_mongoid_attached_file( :image, {:styles => lambda { |img_url|
img_url.instance.image_content_type != "image/svg+xml" ? {
:large => "x248",
:medium => "x64",
:grayscale => { :processors => [:grayscale], :size => "82x82" },
:grayscale_small => { :processors => [:grayscale], :size => "48x48" }
} : {
:large => {write-a-code-to-upload-file-same-as-original-file-with-name-large},
:medium => {write-a-code-to-upload-file-same-as-original-file-with-name-medium}
:grayscale =>
{write-a-code-to-upload-file-same-as-original-file-with-name-grayscale}
:grayscale_small =>
{write-a-code-to-upload-file-same-as-original-file-with-name-grayscal_small} }}}
Gem versions:
*mongoid:* 3.0.15
*paperclip:* 2.3.11
*mongoid-paperclip:* 0.0.8
Please let me know if you have worked on similar requirement. Any pointers
will be highly appreciated.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/97af62aa-072f-4e0a-a984-992bf3a35fc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.