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: 25764
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 » 2016-05-31T14:23:21-07:00

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: 11100
Joined: 2003-05-31T11:32:55-07:00

Re: Rotate image causes black bars and corruption

Post by magick » 2016-05-31T16:38:16-07:00

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: 25764
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 » 2016-05-31T17:12:13-07:00

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 » 2016-05-31T18:37:54-07:00

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: 25764
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 » 2016-05-31T19:14:36-07:00

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 » 2016-05-31T19:26:52-07:00

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 » 2016-05-31T19:50:45-07:00

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: 11100
Joined: 2003-05-31T11:32:55-07:00

Re: Rotate image causes black bars and corruption

Post by magick » 2016-06-01T05:21:34-07:00

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: 11100
Joined: 2003-05-31T11:32:55-07:00

Re: Rotate image causes black bars and corruption

Post by magick » 2016-06-07T08:55:51-07:00

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

Post Reply