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

Not able to disable auto rotate when using thumbnail_image #1146

Closed
becoded opened this issue Oct 30, 2018 · 8 comments
Closed

Not able to disable auto rotate when using thumbnail_image #1146

becoded opened this issue Oct 30, 2018 · 8 comments

Comments

@becoded
Copy link

becoded commented Oct 30, 2018

It seems that the flag auto-rotate for thumbnail_image doesn't have any effect when using vips command line.

Source file: https://github.com/ianare/exif-samples/blob/master/jpg/orientation/portrait_8.jpg

Using the following command:
vips thumbnail_image portrait_8.jpg "portrait_8-600x450.jpg[strip,background=255 255 255,Q=95]" 600 --height=450 --auto-rotate=false

As I specify to strip the metadata + don't do the auto-rotate, I would expect that my end result should be a rotated image but the images displays correctly.

vips --version
vips-8.7.0-Fri Aug 31 14:11:19 UTC 2018

@jcupitt
Copy link
Member

jcupitt commented Oct 30, 2018

Hi @becoded,

You're right, I'd expect

vips thumbnail_image portrait_8.jpg x.jpg 128 --auto-rotate=false

to not rotate, but it does. I'll have a look.

vipsthumbnail seems to only rotate with --rotate option, so that works at least.

@jcupitt
Copy link
Member

jcupitt commented Oct 31, 2018

It's because of the way that glib arg parsing works, sorry, I don't think this is directly fixable.

The best workaround would be to use vipsthumbnail instead, ie. your example would be:

vipsthumbnail portrait_8.jpg -o portrait_8-600x450.jpg[strip,background=255,Q=95] -s 600x450

I think the best solution would be to tag the auto-rotate option as deprecated, and add a new one called no-rotate which defaults to FALSE. Your command-line would then be:

vips thumbnail_image portrait_8.jpg x.jpg 128 --no-rotate

Background: glib command-line switches must take one of two forms:

  1. -v or --verbose. A simple flag, meaning TRUE if present.
  2. -w 12 or --width=12. A switch with a single argument. The argument can be one of several types: string, int, filename etc.

You can't mix the two styles, so a no-arg flag can't have an =arg appended to it.

See https://developer.gnome.org/glib/stable/glib-Commandline-option-parser.html

@becoded
Copy link
Author

becoded commented Oct 31, 2018

Hello @jcupitt

I really appreciate it that you looked into this so fast!

I don't really see your point to be honest.
If I just type vips thumbnail_image
I get

...
   auto-rotate  - Use orientation tags to rotate image upright, input gboolean
			default: true
...

How I read this is as follows:

  • auto-rotate is set to true if you don't define it in the options
  • if you want to change it, it requires an boolean input.

So the only way to use the option auto-rotate is the 2nd form:
--auto-rotate=true or --auto-rotate=false

So it seems that auto-rotate is configured as a simple flag but should be changed to a switch with a single argument.

@jcupitt
Copy link
Member

jcupitt commented Oct 31, 2018

I think the argument is:

  • thumbnail_image has auto-rotate as an optional boolean argument.
  • All boolean arguments are mapped to simple GOption switches, with --thing meaning set thing TRUE
  • However, auto_rotate is default TRUE, so you can never set it FALSE on the command-line.

It was an unfortunate oversight when thumbnail_image was designed.

Anyway, use vipsthumbnail instead for now and you should be OK.

@becoded
Copy link
Author

becoded commented Oct 31, 2018

Will do.
Thanks again for the fast support!

jcupitt added a commit that referenced this issue Oct 31, 2018
the auto_rotate option of thumbnail was default TRUE which made it
useless from the CLI, since GOption only allows --switch, not
--switch=false

deprecate auto_rotate, add no_rotate, but allow either to be used

see #1146
@jcupitt
Copy link
Member

jcupitt commented Oct 31, 2018

OK, fixed in git master. I'll close.

@jcupitt jcupitt closed this as completed Oct 31, 2018
@becoded
Copy link
Author

becoded commented Nov 5, 2018

Hello @jcupitt
I saw there was a new release with these changes included.
Is it expected that I don't see the new option if I do vips thumbnail_image
Also providing the new option gives me an error (Unknown option)

@jcupitt
Copy link
Member

jcupitt commented Nov 5, 2018

Hello, there's 8.7.1, but that's just a bugfix from 8.7.0.

This change will be in 8.8.0, due in the spring some time, or you can build from git master if you want it now.

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

No branches or pull requests

2 participants