emrekutlu / paperclip-compression

image compression processor for Paperclip
MIT License
72 stars 37 forks source link

converting to PNG when compressing #21

Closed jbeyer05 closed 6 years ago

jbeyer05 commented 6 years ago

I have incorporate paperclip-compression in a very simple way, requested that just JPGs get compressed. Configuration as follows:

  has_attached_file :image, processors: [ :rotator, :compression ],
                            styles: {
                              large: {
                                geometry: "1000x1000>",
                                processor_options: {
                                  compression: {
                                    png: false,
                                    jpeg: '-copy none -optimize',
                                  },
                                },
                              },

However, when I reprocess my existing paperclip assets in the rails console, paperclip-compression is saving the file as a .png file. Note the last line in the output below:

Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/d8862f378121712d2600d85f8cf389d620171217-21995-wlrhbw.jpg[0]' 2>/dev/null
Command :: identify -format %m '/tmp/d8862f378121712d2600d85f8cf389d620171217-21995-wlrhbw.jpg[0]'
Command :: convert '/tmp/d8862f378121712d2600d85f8cf389d620171217-21995-wlrhbw.jpg[0]' -auto-orient -resize "300x300>" -quality 85 '/tmp/e51f0c2fffc1d5330fc0279a446e15ce20171217-21995-620q7x'

Command :: /home/andrew/.rvm/gems/ruby-2.4.0/gems/paperclip-compression-1.0.0/bin/linux/x64/jpegtran -copy none -optimize '/tmp/e51f0c2fffc1d5330fc0279a446e15ce20171217-21995-620q7x' > '/tmp/8321bf781908b3041b4a52e67447e78f20171217-21995-ocqwtu.png'

Thoughts as to why this is happening and how to fix it?

jbeyer05 commented 6 years ago

It would seem that the JPEG compressor is using @dst_path, which is set in PaperclipCompression::Base to the value of @dst, which in turn is set to Paperclip::TempfileFactory.new.generate("#{@basename}.png")

Am I misusing the library somehow?

emrekutlu commented 6 years ago

@jbeyer05 it is a bug as you found out, but I could not fully reproduce it. Did you verify that files are really have .png extension in your file system or is it just the temporary files in your output? What is rotator processor? Can you send a link? I want to test exactly like your code.

emrekutlu commented 6 years ago

Removed .png extension with the new 1.0.1 release. Seems like it does nothing.