Image CONVERT ROTATE problems

G'Day,

I've set up some shortcut keys to rotate pictures using dopus's Image Convert command, and it mostly works pretty well, but I've got a couple of problems.

  1. The PRESERVEDATE option doesn't seem to work. It looks like when you use this parameter, the conversion isn't supposed to change the last modified timestamp on the file, but with my command, it does.
    I'm using this command:
Image CONVERT ROTATE=90 HERE REPLACE PRESERVEDATE

but the last modified date changes every time I rotate something. Is this a bug, or is my command wrong?

  1. According to the big Dopus guide, JPEG rotation is supposed to be lossless "where possible". When is it not possible? I find that every time I rotate an image, the filesize increases, which suggests to me that the whole thing is being re-compressed each time.

  2. When I use the built-in image viewer, and use the hotkey I've set up with the above command, it gets run ok, but only on the file that is last selected before entering the viewer. It would be nice if there was some way of rotating files via a hotkey while viewing them, and having the actual file updated. Is there currently any way of doing this?

Any comments are appreciated.

Cheers,
Sam.

Well,
G'Day from the Great Lakes.

  1. I'm sorry, but your code works just fine here.
Image CONVERT ROTATE=90 HERE REPLACE PRESERVEDATE

The 'Modified' column preserves the original date and time on every rotation.
The Opus viewer confirms that this rotation has been done.
If I eliminate the PRESERVEDATE argument, the 'Modified' column displays the current time and date.

Can anyone else confirm either my finding or Shadowfax's ???

  1. I don't know all of this, but instinct tells me that rotation is probably somewhat lossy.
    It is possible I guess when existing data corressponds to the new pixel mapping.
    Think about a pixel to pixel matrix rotation, radian by radian, or degree by degree.
    Something has to give unless all pixels can be mapped one to one !

My file size increased as well for 90 degree rotations.
It's just the algorithm DOpus is using.
Yes, I also think it's wrong, but..... well, as a lame excuse, ..... do other programs you use do better ????
You could try to specify jpeg quality, but actually, I used a gif in my test of your code........

Regards,
Zippo

Lossless jpeg rotation is possible if the image dimensions are a multiple of the block size (normally 16x16, 16x8 or 8x8). See the jpeg faq for more information.

Hey Zippo,

  1. Thanks for testing this for me.
    Interesting that PRESERVEDATE works for you, what version of Dopus are you using? I'm running 8.2.0.2 unicode. I should probably update...

  2. Aaah yes, you're right. I forgot that you can rotate by arbitrary angles. As you say, it's only ever going to be exactly the same size if you rotate by some multiple of 90 degrees, so that explains the comment.

[quote]My file size increased as well for 90 degree rotations.
It's just the algorithm DOpus is using.[/quote]
There's some interesting info here, including a link to some reference jpeg programs, among which is a utility called jpegtran, and confirmation that you can rotate JPEGs losslessly if the angle is a multiple of 90 degrees.
http://en.wikipedia.org/wiki/.JPEG#Usage

If I use it to rotate some some random jpeg like this:

jpegtran.exe -perfect -rotate 180 a.jpg > b.jpg jpegtran.exe -perfect -rotate 180 b.jpg > c.jpg jpegtran.exe -perfect -rotate 180 c.jpg > d.jpg
I get this:

12/11/2006 03:39 PM 474,073 a.jpg 12/11/2006 04:00 PM 458,933 b.jpg 12/11/2006 04:00 PM 458,965 c.jpg 12/11/2006 04:00 PM 458,933 d.jpg

Note that b.jpg and d.jpg are identical in size. (the original - a.jpg is only larger because jpegtran doesn't copy the exif metadata). This is what should be happenning, which the man page for jpegtran confirms.

Doing the same thing with dopus (using Image CONVERT ROTATE=180 HERE REPLACE PRESERVEDATE), I get:

12/11/2006 03:39 PM 474,073 a.jpg 12/11/2006 04:06 PM 479,083 b-dopus.JPG 12/11/2006 04:06 PM 484,157 c-dopus.JPG 12/11/2006 04:06 PM 489,167 d-dopus.JPG

Note the increasing file size.

All of which makes me suspect that dopus is doing something wierd when rotating, maybe re-encoding each time, maybe making multiple copies of the exif data or something. Maybe one of the authors dopus can clear this up?

Oh yeah, you can see the changing timestamps on the dopus rotates as well, despite the inclusion of the PRESERVEDATE switch. This problem is really annoying when you're trying to get a big bunch of photos in order properly, because all the ones you rotate get stuck at the end of your list.

-Sam.