Rotate image causes black bars and corruption

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rotate image causes black bars and corruption

Post by fmw42 »

I suspect that something has changed in Imagemagick whereby it no longer properly switches over to single threaded libjpeg in a multi-threaded environment. You probably were never getting multi-threaded conversion to jpg.

I also sent him a note to review this post when he gets time.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Rotate image causes black bars and corruption

Post by magick »

Post the output of `convert -list format` just for JPEG. It tells us which JPEG library you are using. Are you using libjpeg Turbo?

Edit coders/jpeg.c and force NoThreadSupport in RegisterJPEGImage(), there are about 4 places that its conditionally compiled. That should likely fix the problem. If so, let us know and we will adjust the conditional compile of thread support.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rotate image causes black bars and corruption

Post by fmw42 »

Magick, for my own understanding, is libjpeg multi-threaded or not. He wants to be able to use all 24 processors. He tested -limit thread 1 and it worked fine. But with more than one thread it failed. He said multi-threading worked fine up til 6.9.4.2.
caliguian
Posts: 33
Joined: 2012-08-10T12:15:13-07:00
Authentication code: 67789

Re: Rotate image causes black bars and corruption

Post by caliguian »

magick wrote:Post the output of `convert -list format` just for JPEG. It tells us which JPEG library you are using. Are you using libjpeg Turbo?
Here is the JPEG info shown from `convert -list format`
JPE* rw- Joint Photographic Experts Group JFIF format (80)
JPEG* rw- Joint Photographic Experts Group JFIF format (80)
JPG* rw- Joint Photographic Experts Group JFIF format (80)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rotate image causes black bars and corruption

Post by fmw42 »

There is a more current version of libjpeg. I am on 90.
caliguian
Posts: 33
Joined: 2012-08-10T12:15:13-07:00
Authentication code: 67789

Re: Rotate image causes black bars and corruption

Post by caliguian »

magick wrote:Edit coders/jpeg.c and force NoThreadSupport in RegisterJPEGImage(), there are about 4 places that its conditionally compiled. That should likely fix the problem. If so, let us know and we will adjust the conditional compile of thread support.
It seems like this doesn't fix the issue, but instead simply gets rid of thread support. Is that really the solution here?
caliguian
Posts: 33
Joined: 2012-08-10T12:15:13-07:00
Authentication code: 67789

Re: Rotate image causes black bars and corruption

Post by caliguian »

fmw42 wrote:There is a more current version of libjpeg. I am on 90.
It looks like we're actually using jpeg-turbo, and it’s on 1.4.2.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Rotate image causes black bars and corruption

Post by magick »

Let's see if we can identify which auto-orient algorithm is failing. Try each of these commands and let us know which one returns black bars:
  • convert image.jpg -resize 100% clone.jpg
    convert image.jpg -flop flop.jpg
    convert image.jpg -rotate 180 rot180.jpg
    convert image.jpg -flip flip.jpg
    convert image.jpg -transpose transpose.jpg
    convert image.jpg -rotate 90 rot90.jpg
    convert image.jpg -transverse transverse.jpg
    convert image.jpg -rotate 270 rot270.jpg
We tried them on our 20 core CentOS 7 system, and they returned expected results. If you identify the command that fails, try the same command on a PNG image. Do you get the same results? Try the input image as PNG, then the output, then both.

Also, post the output of this command:
  • convert -list configure
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Rotate image causes black bars and corruption

Post by magick »

Download and install ImageMagick 6.9.4-8 or 7.0.1-10. Do you still get black bars?
Post Reply