Partially black image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
prae
Posts: 4
Joined: 2012-06-30T10:18:27-07:00
Authentication code: 13

Partially black image

Post by prae »

I'm trying to convert an image with the "convert" commandline-tool.
When I try to convert (resize) an image the result image is partially black. It looks like the upper part of the image is processed well.
The image I'm trying to convert is around 5 Mb. When I resize the picture first with Irfanview to 150 Kb and try to convert it again, it works. So it looks like it has something to do with the filesize.

I tried to limit the use of memory/map using the "-limit" argument, but that's not fixing it.

Anyone had that issue before or knows how to fix it?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Partially black image

Post by fmw42 »

run

identify -verbose originalimage

and list the results.


Do the same on the resized image from Irfanview.


We might get some insight into what is going on. Otherwise, you may have to post a link to your image.
prae
Posts: 4
Joined: 2012-06-30T10:18:27-07:00
Authentication code: 13

Re: Partially black image

Post by prae »

This is the file that works after resizing it to 3000x2000 pixels:

Code: Select all

Image: IMG_0992_enhanced2.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Class: DirectClass
  Geometry: 3000x2000+0+0
  Resolution: 150x150
  Print size: 20x13.3333
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 108.033 (0.423659)
      standard deviation: 72.4363 (0.284064)
      kurtosis: -1.02719
      skewness: 0.441946
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 120.471 (0.472434)
      standard deviation: 76.6508 (0.300591)
      kurtosis: -1.31444
      skewness: 0.356841
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 114.868 (0.450464)
      standard deviation: 89.5408 (0.35114)
      kurtosis: -1.46906
      skewness: 0.323324
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 114.457 (0.448853)
      standard deviation: 79.8747 (0.313234)
      kurtosis: -1.25222
      skewness: 0.376435
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 3000x2000+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 100
  Orientation: TopLeft
  Properties:
    date:create: 2012-06-30T20:11:52+02:00
    date:modify: 2012-06-30T20:11:52+02:00
    exif:ApertureValue: 352256/65536
    exif:ColorSpace: 1
    exif:ComponentsConfiguration: 1, 2, 3, 0
    exif:Compression: 6
    exif:CustomRendered: 0
    exif:DateTime: 2012:06:13 19:53:13
    exif:DateTimeDigitized: 2012:06:13 19:53:13
    exif:DateTimeOriginal: 2012:06:13 19:53:13
    exif:ExifImageLength: 2000
    exif:ExifImageWidth: 3000
    exif:ExifOffset: 271
    exif:ExifVersion: 48, 50, 50, 49
    exif:ExposureBiasValue: 0/1
    exif:ExposureMode: 0
    exif:ExposureTime: 1/80
    exif:Flash: 16
    exif:FlashPixVersion: 48, 49, 48, 48
    exif:FNumber: 63/10
    exif:FocalLength: 20/1
    exif:FocalPlaneResolutionUnit: 2
    exif:FocalPlaneXResolution: 4752000/894
    exif:FocalPlaneYResolution: 3168000/597
    exif:GPSInfo: 5027
    exif:GPSVersionID: 2, 2, 0, 0
    exif:InteroperabilityIndex: R98
    exif:InteroperabilityOffset: 4957
    exif:InteroperabilityVersion: 48, 49, 48, 48
    exif:ISOSpeedRatings: 100
    exif:JPEGInterchangeFormat: 5139
    exif:JPEGInterchangeFormatLength: 8369
    exif:Make: Canon
    exif:MakerNote: (lots of data here)
    exif:Model: Canon EOS 50D
    exif:Orientation: 1
    exif:RelatedImageLength: 4000
    exif:RelatedImageWidth: 2667
    exif:ResolutionUnit: 2
    exif:SceneCaptureType: 0
    exif:ShutterSpeedValue: 417792/65536
    exif:Software: Digital Photo Professional
    exif:UserComment: (lots of data here)
    exif:WhiteBalance: 1
    exif:XResolution: 150/1
    exif:YCbCrPositioning: 1
    exif:YResolution: 150/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: f2f8a9a53be1594c62f156dbfcc44d4014ef48122788345d7d28783b8b4ee20d
    unknown: 6
  Profiles:
    Profile-exif: 13516 bytes
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 3.393MBB
  Number pixels: 6MB
  Pixels per second: 569KB
  User time: 2.780u
  Elapsed time: 0:11.540
  Version: ImageMagick 6.6.9-1 2012-02-14 Q16 http://www.imagemagick.org

And this is the larger file, 4000x2667 (not working):

Code: Select all

Image: IMG_0992_enhanced.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Class: DirectClass
  Geometry: 4000x2667+0+0
  Resolution: 150x150
  Print size: 26.6667x17.78
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 66.346 (0.26018)
      standard deviation: 91.5795 (0.359135)
      kurtosis: -0.956096
      skewness: 0.861078
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 74.3483 (0.291562)
      standard deviation: 100.489 (0.394075)
      kurtosis: -1.25852
      skewness: 0.751861
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 77.8976 (0.305481)
      standard deviation: 106.209 (0.416507)
      kurtosis: -1.31836
      skewness: 0.742659
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 72.8639 (0.285741)
      standard deviation: 99.6081 (0.39062)
      kurtosis: -1.15619
      skewness: 0.797759
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 4000x2667+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 98
  Orientation: TopLeft
  Properties:
    date:create: 2012-06-30T19:09:50+02:00
    date:modify: 2012-06-28T22:12:54+02:00
    exif:ApertureValue: 352256/65536
    exif:ColorSpace: 1
    exif:ComponentsConfiguration: 1, 2, 3, 0
    exif:Compression: 6
    exif:CustomRendered: 0
    exif:DateTime: 2012:06:13 19:53:13
    exif:DateTimeDigitized: 2012:06:13 19:53:13
    exif:DateTimeOriginal: 2012:06:13 19:53:13
    exif:ExifImageLength: 2667
    exif:ExifImageWidth: 4000
    exif:ExifOffset: 271
    exif:ExifVersion: 48, 50, 50, 49
    exif:ExposureBiasValue: 0/1
    exif:ExposureMode: 0
    exif:ExposureTime: 1/80
    exif:Flash: 16
    exif:FlashPixVersion: 48, 49, 48, 48
    exif:FNumber: 63/10
    exif:FocalLength: 20/1
    exif:FocalPlaneResolutionUnit: 2
    exif:FocalPlaneXResolution: 4752000/894
    exif:FocalPlaneYResolution: 3168000/597
    exif:GPSInfo: 5027
    exif:GPSVersionID: 2, 2, 0, 0
    exif:InteroperabilityIndex: R98
    exif:InteroperabilityOffset: 4957
    exif:InteroperabilityVersion: 48, 49, 48, 48
    exif:ISOSpeedRatings: 100
    exif:JPEGInterchangeFormat: 5139
    exif:JPEGInterchangeFormatLength: 8369
    exif:Make: Canon
    exif:MakerNote: (lots of date here)
    exif:Model: Canon EOS 50D
    exif:Orientation: 1
    exif:RelatedImageLength: 4000
    exif:RelatedImageWidth: 2667
    exif:ResolutionUnit: 2
    exif:SceneCaptureType: 0
    exif:ShutterSpeedValue: 417792/65536
    exif:Software: Digital Photo Professional
    exif:UserComment: (lots of date here)
    exif:WhiteBalance: 1
    exif:XResolution: 150/1
    exif:YCbCrPositioning: 1
    exif:YResolution: 150/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x1,1x1,1x1
    signature: 41674241d9ba5026a26d17a7f12214db20783accad67eb0b23785b97b0eb5c4a
    unknown: 6
  Profiles:
    Profile-exif: 13516 bytes
    Profile-icc: 3140 bytes
      sRGB v1.31 (Canon) - Canon Inc.
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 5.209MBB
  Number pixels: 10.67MB
  Pixels per second: 601KB
  User time: 5.110u
  Elapsed time: 0:18.760
  Version: ImageMagick 6.6.9-1 2012-02-14 Q16 http://www.imagemagick.org
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Partially black image

Post by fmw42 »

Your input image at 4000x2667 is thus 32 Mbytes (for all 3 channels). You will need at least twice that much for the resize. Do you have that much memory? If not, then it is thrashing to disk and will be very slow. So you need to wait or see

http://www.imagemagick.org/Usage/files/#massive

But even that will be slow, though not as slow as not using that.
prae
Posts: 4
Joined: 2012-06-30T10:18:27-07:00
Authentication code: 13

Re: Partially black image

Post by prae »

Tnx for the answer!

It does take a long time. But that doesn't explain/fix the black part at the bottom of the picture.
I'll have look at the 'large file' examples, tnx for that!

Image
wvooster
Posts: 1
Joined: 2012-11-16T06:43:22-07:00
Authentication code: 6789

Re: Partially black image

Post by wvooster »

Hello,

This happened to some of my pictures as well.
I nailed it down to ImageMagick using /tmp as a temporary folder, which was not large enough. I do not precisely know why these particular pictures require a large temporary space. If I scale them down to - let's say 90% - that is the difference between using 32 MB or over 140 MB.
Increasing the /tmp folder (or pointing ImageMagick to use an other temporary folder with sufficient space) did the trick.

Hope this helps for you as well

Cheers
prae
Posts: 4
Joined: 2012-06-30T10:18:27-07:00
Authentication code: 13

Re: Partially black image

Post by prae »

Tnx for your help! Changing the temp. folder did the trick! Adding the following to the 'convert' command fixed the problem:

Code: Select all

-define registry:temporary-path=/path/to/location/with/plenty/of/space
Post Reply