Page 1 of 1

Rotate bug in Windows?

Posted: 2013-12-15T05:28:06-07:00
by watusimoto
When I give this command on Windows:

Code: Select all

convert -size 40x40 xc:black -fill black -stroke yellow -strokewidth 1 -draw "translate 20,20 line -2,2, 0,6  line 0,6 2,2  line 2,2 6,0  line 6,0 2,-2  line 2,-2 0,-6  line 0,-6 -2,-2  line -2,-2 -6,0  line -6,0 -2,2  stroke red   rotate 45  line -2,2, 0,8  line 0,8, 2,2  line 2,2, 8,0  line 8,0, 2,-2  line 2,-2, 0,-8  line 0,-8, -2,-2  line -2,-2, -8,0  line -8,0, -2,2" xxx.jpg
I expect this output: Image

Instead I get something like this: Image

It does, however, appear to work as expected in Linux.

When I enter this on Windows (notice the additional translates in the middle):

Code: Select all

convert -size 40x40 xc:black -fill black -stroke yellow -strokewidth 1 -draw "translate 20,20 line -2,2, 0,6  line 0,6 2,2  line 2,2 6,0  line 6,0 2,-2  line 2,-2 0,-6  line 0,-6 -2,-2  line -2,-2 -6,0  line -6,0 -2,2  stroke red  translate -20,-20 rotate 45 translate 20,20 line -2,2, 0,8  line 0,8, 2,2  line 2,2, 8,0  line 8,0, 2,-2  line 2,-2, 0,-8  line 0,-8, -2,-2  line -2,-2, -8,0  line -8,0, -2,2" xxx.jpg
I expect to get the broken image above (as I do on Linux), but instead I get the correct image above.

Is this a bug?

Re: Rotate bug in Windows?

Posted: 2013-12-15T05:56:58-07:00
by snibgo
Your second image doesn't show.

If you are getting different results on different machine, I suspect you are using different versions of IM. What versions are they?

On Windows 7, IM v6.8.7-0, my result looks like yours.

Re: Rotate bug in Windows?

Posted: 2013-12-15T08:13:37-07:00
by watusimoto
The second image is: Image

I am not sure about the Linux version -- I had posted the above code on an IRC forum and got a complaint from another user. The Windows version is "ImageMagick 6.6.5-3 2010-10-22 Q16"... which looks rather old considering I just downloaded it last night.

Regardless, I think the Windows output is wrong -- the first code block should produce the expected output, unless the documentation is misleading/wrong. In order to rotate the canvas about the center, why do I need to do "translate -20,-20 rotate 45 translate 20,20" instead of just a straight rotate? Remember that at the beginning I have a "translate 20,20" which should put the center of rotation into the center of the image.

Re: Rotate bug in Windows? [[Resolved]]

Posted: 2013-12-15T08:29:31-07:00
by watusimoto
Ok, it seems to be a version issue. I reinstalled imagemagick, carefully making sure I was really installing the latest, and now things work as expected.

Sorry for the false alarm!

Re: Rotate bug in Windows?

Posted: 2013-12-15T08:42:28-07:00
by snibgo
v6.6.5 is ancient. There are many old versions floating around the internet. I suggest always installing from the official page. Windows binaries are at http://www.imagemagick.org/script/binar ... hp#windows

Re: Rotate bug in Windows?

Posted: 2013-12-15T16:43:37-07:00
by watusimoto
The odd thing is I did install from the official page. But there was probably user error in the process somewhere.

Re: Rotate bug in Windows?

Posted: 2014-01-15T16:55:04-07:00
by texervn
Hello everyone,

This is the first time I post in this forum.

I have a problem with ImageMagick in Windows 8.1 (x64) because it doesn't function normally as It does on Windows XP.

1) I just use -rotate 180 options to rotate the image (scanned tif, text); however, the resulted image is really big (size) compare to the original one. This issue doesn't happen in my Windows XP (the same image, same command:

Code: Select all

convert file.tif -rotate 180 file1.tif
)

2) Another problem is that when I use command:

Code: Select all

convert file-w8.tif -size 3952x5799 -fill white -draw "rectangle 3755,0 3952,5799" file-blur.tif
to remove some black boxes in the scanned image. The output image is blurry and it has double size though.

You can check some files that I used in my example here:
https://shared.com/g1rgweykrv?s=l

Any help is really appreciated.

Thank you.

Re: Rotate bug in Windows?

Posted: 2014-01-15T16:59:05-07:00
by fmw42
convert file-w8.tif -size 3952x5799 -fill white -draw "rectangle 3755,0 3952,5799" file-blur.tif
What is the purpose of -size 3952x5799? In your command, it likely does nothing.

Re: Rotate bug in Windows?

Posted: 2014-01-15T17:05:03-07:00
by fmw42
convert file.tif -rotate 180 file1.tif
This works fine on my Mac OSX, IM 6.8.8.2 Q16

The issue with size is that your input is LZW compressed, but the output has no compression. So add -compress lzw to your command. Apparently, IM is not preserving the compression between input and output.

see
http://www.imagemagick.org/script/comma ... p#compress

PS. Your input has a totally opaque alpha channel. That is also a waste of space. So add -alpha off to your command as well.

convert test.tiff -alpha off -rotate 180 -compress lzw test3.tiff

file size = 266KB (compared to the original 566KB)

Re: Rotate bug in Windows?

Posted: 2014-01-15T17:19:45-07:00
by texervn
Thank for your quickly replying.

I read it some where to put the -size options because I just started using IM (very newbie :))

The original image is file.tif which has 90.1 KB (92,287 bytes), and output image, after rotating, removing black boxes in Win XP, is 81.1 KB (83,063 bytes) (file-xp.tif)

However, on Win8.1, the size at the end is 2.73 MB (2,867,961 bytes) (file-w8.tif)

Do we have another way to remove some black boxes without using -fill white -draw "rectangle 3755,0 3952,5799" option?

Thanks.

PS: I'm using IM 6.8.8-2-x64-dll, Windows 8.1, x64.

Re: Rotate bug in Windows?

Posted: 2014-01-15T17:32:38-07:00
by fmw42
In your command it appears that all you are doing is adding white to right side of the image where it already white. There is nothing wrong with your command if you want to overlay white by using -draw. (You could just create a second white image and composite it where you want. For that you would need -size, but not -draw).

The issue with size is the same as in my earlier post. You need to remove any alpha channel (in this case fully opaque) and reset the compression of your output tiff to lzw.

For using composite, you could have done the following.

convert file-w8.tif -alpha off -size 3952x5799 xc:white -geometry +3755+0 -composite -compress lzw file-blur.tif

or your original

convert file-w8.tif -alpha off -fill white -draw "rectangle 3755,0 3952,5799" -compress lzw file-blur.tif


See
http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/layers/#draw


I suspect that the main issue here is that at some point in time, IM was changed and no longer creates the tiff output with the same compression as the tiff input. If you think this is a bug and can show it changed between releases, you could report this on the Bugs forum.

Re: Rotate bug in Windows?

Posted: 2014-01-15T17:42:02-07:00
by texervn
convert file-w8.tif -alpha off -size 3952x5799 xc:white -geometry +3755+0 -composite -compress lzw file-blur.tif
Great! Your command works very well. So the reason for making it blurry is because of the alpha channel:D

However, I'm still wondering that the size I got (using your command) is 260 KB (266,365 bytes); it is quite big compare to the one on Windows XP: 81.1 KB (83,063 bytes).

Thanks fmw42.

Re: Rotate bug in Windows?

Posted: 2014-01-15T17:50:57-07:00
by fmw42
I am not sure why you say it was blurry. The alpha channel, which could have done some anti-aliasing, appears to be totally white (opaque). So there should not have been any antialiasing.

I am not sure about your windows system. I work on a Mac and know nothing about Windows. However, might I ask if the two versions of IM are your two systems are exactly the same? try

convert -version

on both systems. It could have been a bug in -draw in one version that was working properly in the other system.

The size issue again is likely on one version of IM, the compression was carried over to the output. In the other system, it was not carried over to the output.

P.S. In the future, please start a new post rather than adding to some other similar post. Your problem is not exactly the same as the original poster. So it gets more confusing when a new post is not created.

Re: Rotate bug in Windows?

Posted: 2014-01-15T17:59:35-07:00
by texervn
fmw42 wrote:However, might I ask if the two versions of IM are your two systems are exactly the same? try

convert -version

on both systems. It could have been a bug in -draw in one version that was working properly in the other system.
I just checked on both computers.
WinXP: IM 6.8.6-10
Win8.1: IM 6.8.8-2

So they are different, that may be the reason for my issue. I will check again with their LOG.
fmw42 wrote:P.S. In the future, please start a new post rather than adding to some other similar post. Your problem is not exactly the same as the original poster. So it gets more confusing when a new post is not created.
Thanks fmw42, this is the first time I posted my question. I will take this into account for the next time.

I appreciate your help.

texervn.

Re: Rotate bug in Windows?

Posted: 2014-01-15T18:05:44-07:00
by fmw42
Thanks fmw42, this is the first time I posted my question. I will take this into account for the next time.

I appreciate your help.

You are welcome.


For future reference, you might review viewtopic.php?f=1&t=9620

For new users, also see
http://www.imagemagick.org/Usage/
http://www.imagemagick.org/Usage/reference.html