Sgi header issue

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.
monark
Posts: 13
Joined: 2016-09-14T03:36:35-07:00
Authentication code: 1151

Sgi header issue

Post by monark »

I'm finding a random error where Imagemagick fails to load some sgi's due to what it thinks is a header error

This is the error
magick: improper image header `I:/Ifa2/Actions/Render/Pushup/Motion1/Layer2\stills\sgi\0841.sgi' @ error/sgi.c/ReadSGIImage/535
magick: no image to apply a property "%w" @ warning/property.c/GetMagickPropertyLetter/2550.
magick: unknown image property "%w" @ warning/property.c/InterpretImageProperties/3489.
magick: no image to apply a property "%h" @ warning/property.c/GetMagickPropertyLetter/2438.
magick: unknown image property "%h" @ warning/property.c/InterpretImageProperties/3489.
magick: no image to apply a property "%m" @ warning/property.c/GetMagickPropertyLetter/2469.
magick: unknown image property "%m" @ warning/property.c/InterpretImageProperties/3489.

I can't see how to upload an image or I would post an example one.

Other programs like Xnview are able to read the file with no issues

The files with issues are part of a large sequence where every other image loads fine, it just seems to have an issue with odd random single files.
Even if I re-save it from Xnview it comes up with the same error.
Even if I save it as a png and then re-save it as an sgi I still get the error, nothing clears it.

I'm using this commandline

'magick ' + sgiPath + ' -background gray(95%) -alpha remove ' + jpgPath

Imagemagick version is ImageMagick-7.0.3-Q16
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Sgi header issue

Post by snibgo »

You can upload to somewhere like dropbox.com, and paste the URL here.
snibgo's IM pages: im.snibgo.com
monark
Posts: 13
Joined: 2016-09-14T03:36:35-07:00
Authentication code: 1151

Re: Sgi header issue

Post by monark »

User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sgi header issue

Post by fmw42 »

On my Mac OSX with Imagemagick 6.9.5-10 Q16 or 7.0.3-1 Q16, it seems to work fine.

Code: Select all

Image: 0041.sgi
  Format: SGI (Irix RGB image)
  Class: DirectClass
  Geometry: 660x660+0+0
  Units: Undefined
  Type: TrueColorAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
  Channel statistics:
    Pixels: 435600
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 9.50784 (0.0372857)
      standard deviation: 39.3359 (0.154258)
      kurtosis: 17.8598
      skewness: 4.31376
      entropy: 0.10717
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 10.0065 (0.0392413)
      standard deviation: 40.2062 (0.157671)
      kurtosis: 15.3567
      skewness: 4.05375
      entropy: 0.106005
    Blue:
      min: 0 (0)
      max: 249 (0.976471)
      mean: 7.7673 (0.03046)
      standard deviation: 32.6173 (0.127911)
      kurtosis: 18.6877
      skewness: 4.40655
      entropy: 0.105675
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 15.577 (0.0610862)
      standard deviation: 60.3983 (0.236856)
      kurtosis: 11.4984
      skewness: -3.66378
      entropy: 0.0543975
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 66.6762 (0.261475)
      standard deviation: 44.3725 (0.17401)
      kurtosis: 78.3952
      skewness: 16.0696
      entropy: 0.0933121
  Alpha: none   #00000000
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 660x660+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: RLE
  Orientation: Undefined
  Properties:
    date:create: 2016-09-23T09:17:02-07:00
    date:modify: 2005-09-23T13:51:22-07:00
    label: H:/Ifa2/Actions/Render/Pushup/Motion1/Layer2/stills/sgi/0041.sgi
    signature: c9c4d63579b5ef5f3f0034db905fb196a2170516d933b287a345ece524a5ccd4
  Artifacts:
    filename: 0041.sgi
    verbose: true
  Tainted: False
  Filesize: 157KB
  Number pixels: 436K
  Pixels per second: 21.78MB
  User time: 0.030u
  Elapsed time: 0:01.019
  Version: ImageMagick 6.9.5-10 Q16 x86_64 2016-09-21 http://www.imagemagick.org

Code: Select all

convert 0041.sgi 0041.png
and

Code: Select all

magick 0041.sgi 0041.png

No header or other errors reported.


This also works fine:

Code: Select all

magick 0041.sgi -background "gray(95%)" -alpha remove 0041.jpg
On Unix-like platforms, you should put quotes around any color specification other than a named color.

What is your platform? I did not see that mentioned.
monark
Posts: 13
Joined: 2016-09-14T03:36:35-07:00
Authentication code: 1151

Re: Sgi header issue

Post by monark »

hmm me too, so why does it like being called from inside a python script... unless I copy the wrong example file....will investigate on Monday
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sgi header issue

Post by fmw42 »

magick: improper image header `I:/Ifa2/Actions/Render/Pushup/Motion1/Layer2\stills\sgi\0841.sgi' @ error/sgi.c/ReadSGIImage/535
Your path has both forward and back slashes. Is that intentional? Why the mixed notation (unix vs windows)?
monark
Posts: 13
Joined: 2016-09-14T03:36:35-07:00
Authentication code: 1151

Re: Sgi header issue

Post by monark »

Python tends to do that when dealing with windows paths unless you force it not to. As I say it's processed in the region of 100 thousand files without complaint but in the case of about a dozen I get the above error.
Looks like I can at the very least process them by hand, but I'd like to get to the bottom of why as finding them is very time consuming.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sgi header issue

Post by fmw42 »

If you looped over this image multiple times, would it fail every time? Perhaps you are running out of resources, such as temp space or exceeding some other limit.
monark
Posts: 13
Joined: 2016-09-14T03:36:35-07:00
Authentication code: 1151

Re: Sgi header issue

Post by monark »

oh I see I did copy the wrong file, it should have been 0841.sgi not 0041.sgi, I'm totally losing it

Try this one
http://stage.anatomy.tv/atv2/bug/0841.zip

Sorry for the confusion. At least you have an example of a good one and a bad one, both generated originally in identical fashion.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sgi header issue

Post by fmw42 »

Yes, that one is corrupt.

Code: Select all

identify -verbose 0841.sgi
identify: improper image header `0841.sgi' @ error/sgi.c/ReadSGIImage/541.

But I cannot help further to tell you why.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sgi header issue

Post by fmw42 »

I was able to open the file in another tool and it has horizontal broken stripes of color in the middle of the file. Looks like the rows have become jumbled or offset.
monark
Posts: 13
Joined: 2016-09-14T03:36:35-07:00
Authentication code: 1151

Re: Sgi header issue

Post by monark »

Hmm ok that one was clearly a bad example seems that there must be more than one issue here.

Let's try this one, this one opens fine in xnview just double chacked it.

And gives me this error when I try and convert it

magick: improper image header `0001.sgi' @ error/sgi.c/ReadSGIImage/535.
magick: no image to apply a property "%w" @ warning/property.c/GetMagickPropertyLetter/2550.
magick: unknown image property "%w" @ warning/property.c/InterpretImageProperties/3489.
magick: no image to apply a property "%h" @ warning/property.c/GetMagickPropertyLetter/2438.
magick: unknown image property "%h" @ warning/property.c/InterpretImageProperties/3489.
magick: no image to apply a property "%m" @ warning/property.c/GetMagickPropertyLetter/2469.
magick: unknown image property "%m" @ warning/property.c/InterpretImageProperties/3489.

http://stage.anatomy.tv/atv2/bug/0001.zip
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sgi header issue

Post by fmw42 »

I suspect that your file is not formed to full specifications and IM will balk at the bad header. Other tools may be more forgiving. I still get your error.

Code: Select all

identify -verbose 0001.sgi
identify: improper image header `0001.sgi' @ error/sgi.c/ReadSGIImage/541.

Final say will have to come from one of the IM developers.

What tool is creating these files?
monark
Posts: 13
Joined: 2016-09-14T03:36:35-07:00
Authentication code: 1151

Re: Sgi header issue

Post by monark »

These come from a 3d package, Houdini from Sidefx. They are usually spot on with specs. What's odd is these ones come from the compositor not straight from the renderer.
And what I don't understand is even if I re-write them or save them to another format it still chokes.
You'd think writing as a png would change the header.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sgi header issue

Post by fmw42 »

If the IM software cannot read the file and complains about the header being malformed, then it won't write the file.

The IM developer will need to look at the file and see what is wrong with the header.

If it is truly malformed and they cannot fix it, then you may have to convert it with some other tool that is more forgiving.
Post Reply