-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version from original file instead of other version #1602
Comments
+1 Given process resize_to_limit: [1600, 1600]
process :store_geometry
version :optimized do
process :pngquant
process :optimize
process :store_geometry
end
version :large, from_version: :optimized do
process resize_to_limit: [1400, 1400]
process :store_geometry
end The original file is 2.5MB. The optimized version is 900KB. And the large version is 1.8MB. If the large version were in fact built from the optimized version, I would expect it to be smaller than 900KB, not twice the size. |
Any updates on this? I'm still having this issue on v1.1.0 When uploading a PDF and wanting multiple PNG thumbnails, it would be nice if this code would work; version :thumb_512, if: :thumbnailable? do
process efficient_conversion: [512, 512]
def full_filename (for_file = model.attached_file.file)
super.chomp(File.extname(super)) + '.png'
end
end
version :thumb_256, from_version: :thumb_512 do
process resize_to_fit: [256, 256]
end
protected
def efficient_conversion(width, height)
manipulate! do |img|
img.format('png')
img.combine_options do |c|
c.fuzz "3%"
c.trim
c.resize "#{width}x#{height}>"
c.resize "#{width}x#{height}<"
end
img
end
end
def thumbnailable?(file)
file.content_type.start_with?('image') || file.content_type == 'application/pdf'
end :thumb_512 will create a 512x512 PNG file of the cover page of the PDF with the appropriate file extension thanks to the naming block. What I would expect to happen with :thumb256 is that it would process the 512x512 PNG with .png file extension. Instead what it does using this block of code is generate a PDF, ie. it looks like it's working on the original file, rather than the :thumb_512 version. So what I end up having to do is do multiple conversions of PDF to PNG for each thumbnail I want, and repeat the full_filename method in each version. Needless to say, the resulting code looks unnecessarily repetitive as well as generating an unnecessary load on the server due to the multiple conversions, rather than just one. |
Fixed by #1879. |
I have the following code in my uploader:
Unfortunately
thumb
version is created based on original file (always in PDF format). That file is broken because it is PDF as well (instead of PNG, likelarge
version).I noticed that
large
version is generated by command likeconvert /tmp/mini_magick20150318-4571-1ma89u5.pdf[0] -density 200 -quality 100 /tmp/mini_magick20150318-4571-ifujor.png
andthumb
uses PDF file:mogrify -resize 200x200 /tmp/mini_magick20150318-4571-5or0in.pdf
The text was updated successfully, but these errors were encountered: