Rotating jpeg image gives weird output
Hi, I have a jpeg image that drives me crazy. The scanned image I have received from the author is in landscape. So, I've rotated the image, but now two things happen: 1. there's a weird offset (the image is moved to the right) 2. The output contains this line . location=local,global. location=local,global I'm not quite quite sure how I can produce a MWE that shows the problem, but has anyone ever seen something like this? Does anyone know what that < . location=local,global. location=local,global > stuff means? Best, Denis P.S: I've performed the rotations using the standard picture editor on Windows and with GIMP. Happens with both tools.l P.S.S.: This seems to be somehow related to the particular file. With a different file that does not happen.
So, I've rotated the image, but now two things happen:
1. there's a weird offset (the image is moved to the right)
This seems to be somehow related to the particular file. With a different file that does not happen.
This can sometimes happen if the image has an embedded EXIF "Orientation" tag and you're using a buggy viewer. Really old versions of Firefox/pdf.js had this bug. If this is the case, you should be able to reproduce it with the following bash commands: convert -size 64x256 canvas:grey -fill black -draw "circle 32,128 16,112" demo1.jpg exiftool -Orientation='Rotate 90 CW' demo1.jpg -o demo2.jpg Then, include "demo1.jpg" and "demo2.jpg" in a ConTeXt file using \externalfigure. Both pictures should display as circles; if you get ovals, then it's definitely EXIF-related.
2. The output contains this line . location=local,global. location=local,global
Never seen this before, which makes me suspect that maybe this isn't EXIF-related. Maybe the image is just subtly corrupted? Anyways, if the problem is EXIF-related, then opening and saving the image file with MS Paint (or any other non-EXIF-aware editor) should fix things. Otherwise, I have no suggestions. -- Max
Thanks for your suggestions. It probably is not EXIF-related. I've opened and saved the image with MS Paint, but that did not change anything (the increase in file size aside...). Any other ideas? (I tend to think the image is corrupted in one way or the other, but I have no clue how to fix that.) Best, Denis
-----Ursprüngliche Nachricht----- Von: Max Chernoff
Gesendet: Dienstag, 14. Juni 2022 11:45 An: ntg-context@ntg.nl Cc: Maier, Denis Christian (UB) Betreff: Re: [NTG-context] Rotating jpeg image gives weird output So, I've rotated the image, but now two things happen:
1. there's a weird offset (the image is moved to the right)
This seems to be somehow related to the particular file. With a different file that does not happen.
This can sometimes happen if the image has an embedded EXIF "Orientation" tag and you're using a buggy viewer. Really old versions of Firefox/pdf.js had this bug. If this is the case, you should be able to reproduce it with the following bash commands:
convert -size 64x256 canvas:grey -fill black -draw "circle 32,128 16,112" demo1.jpg exiftool -Orientation='Rotate 90 CW' demo1.jpg -o demo2.jpg
Then, include "demo1.jpg" and "demo2.jpg" in a ConTeXt file using \externalfigure. Both pictures should display as circles; if you get ovals, then it's definitely EXIF-related.
2. The output contains this line . location=local,global. location=local,global
Never seen this before, which makes me suspect that maybe this isn't EXIF- related. Maybe the image is just subtly corrupted?
Anyways, if the problem is EXIF-related, then opening and saving the image file with MS Paint (or any other non-EXIF-aware editor) should fix things. Otherwise, I have no suggestions.
-- Max
Any other ideas? (I tend to think the image is corrupted in one way or the other, but I have no clue how to fix that.)
You could try making a new image with the same content. Assuming you're on Windows 10/11, install Image Magick winget install -e --id ImageMagick.ImageMagick then run magick convert -strip image.jpg temp.tga magick convert -strip temp.tga new-image.jpg del temp.tga which should give you a new image "new-image.jpg" that shouldn't be corrupt. If you are still having problems with this new image, then the issue is likely with ConTeXt itself, and this specific image is just triggering it somehow. -- Max
Thanks for all your help. Using Magick had no effect so I've had another look at my setup. It turned out I had this in m \setupexternalfigures [maxwidth=\textwidth, maxheight=0.8\textheight. location={local,global}, ] The period to end maxheight is obviously a mistake. (However, I'm still perplexed that this only shows up when the image is rotated...) Sorry for the noise. Denis
-----Ursprüngliche Nachricht----- Von: Max Chernoff
Gesendet: Mittwoch, 15. Juni 2022 00:52 An: Maier, Denis Christian (UB) ; ntg-context@ntg.nl Betreff: Re: [NTG-context] Rotating jpeg image gives weird output Any other ideas? (I tend to think the image is corrupted in one way or the other, but I have no clue how to fix that.)
You could try making a new image with the same content. Assuming you're on Windows 10/11, install Image Magick
winget install -e --id ImageMagick.ImageMagick
then run
magick convert -strip image.jpg temp.tga magick convert -strip temp.tga new-image.jpg del temp.tga
which should give you a new image "new-image.jpg" that shouldn't be corrupt. If you are still having problems with this new image, then the issue is likely with ConTeXt itself, and this specific image is just triggering it somehow.
-- Max
participants (2)
-
denis.maier@unibe.ch
-
Max Chernoff