Skip to content
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

writing jpg appears to invert colors #33

Open
bburdette opened this issue Aug 2, 2016 · 3 comments
Open

writing jpg appears to invert colors #33

bburdette opened this issue Aug 2, 2016 · 3 comments

Comments

@bburdette
Copy link

bburdette commented Aug 2, 2016

Playing around with imagez today; this one-liner unexpectedly inverts the jpg colors.

imagemeh.core=> (require '[mikera.image.core :as mic])
nil
imagemeh.core=> (mic/write (mic/load-image "download.jpg") "inverted.jpg" "jpg")
nil

source and result images attached:

download
inverted

Writing to PNG produces a normal looking image.

@mercul3s
Copy link

I'm also experiencing this issue when resizing and writing jpgs. Any suggestions? This is a snippet from the code I'm having trouble with:

(defn image-resize [image width height]
    (let [loaded-image (core/load-image image)
          resized-image (core/resize loaded-image width height)
          new-image-name (format-image-name image width height)]
    (core/save resized-image new-image-name :quality 1.0 :progressive true)))

@mikera
Copy link
Owner

mikera commented Apr 13, 2017

Might be related to this:

http://stackoverflow.com/questions/9340569/jpeg-image-with-wrong-colors

Don't really use JPEGs myself but happy to take a PR if anyone can work out what is going wrong...

@mercul3s
Copy link

I did some digging, and it looks like jpg colorspace is being converted from RGB to CMYK as the Java Image Writer lib adds an alpha channel. On save, it writes as CMYK because of the 4th channel. Could potentially be fixed by stripping that 4th channel before save:
rkalla/imgscalr#82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants