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.
Yes, there is still a problem with ruby gem versions I am using. Using above resize :styles code, produced SVG images are invalid xml, and do not open in browser. So I want to upload as it is.
Yes, there is still a problem with ruby gem versions I am using. Using above
resize :styles code, produced SVG images are invalid xml, and do not open in
browser. So I want to upload as it is.
Currently I am working on a ROR code which uses rails paperclip gem.
My requirement is, to process images as per its file extension.
Here's how I solved this for a document management system that needed transcoding for video, resizing for images, and nothing for every other file type (zip, powerpoint, etc.).
def file_styles(a)
if a.video?
return {
:thumb => { :geometry => "320x320>", :format => 'jpg', :time => 1 },
:poster => { :geometry => "1280x720>", :format => 'jpg', :time => 1 },
:mp4 => { :geometry => "1280x720>", :format => :mp4, :streaming => true }
}
end
if a.photo?
return { :thumb => ["320x320>", :png], :large => ["1500x1500>", :png] }
end
if a.audio?
return { :wav => ['audio', :wav], :mp3 => ['audio', :mp3] }
end
{} # if you get here, then there are no styles needed, just the original
end
def processors(a)
if a.video?
return [:ffmpeg, :qtfaststart]
end
if a.photo?
return [ :my_thumbnail ]
end
if a.audio?
return [ :audio ]
end
# if you get here, then no processing needed
end
Currently I am working on a ROR code which uses rails paperclip gem.
My requirement is, to process images as per its file extension.
Here's how I solved this for a document management system that needed transcoding for video, resizing for images, and nothing for every other file type (zip, powerpoint, etc.).
Did you realise that was superseded in Feb 2012 and there have been
critical security fixes since then? That version is not suitable for
use. If this is a new app then start again with Rails version 4, if
an existing one then at least upgrade to the latest 3.1 immediately,
and then migrate to 4 when you can.