Resizing with GraphicsMagic inverts image

I’ve got an odd problem using GraphicsMagic (MBS). I’m using the following code to resize and reorient images (attachments from emails):

Dim blob As New GMBlobMBS(MimeData)
Dim image As New GMImageMBS(blob)
'scale larger images
if (image.rows >= myPreviewSize or image.columns >= myPreviewSize) then 
  dim geo as new GMGeometryMBS(myPreviewSize, myPreviewSize)
end if

PreviewPic = image.CombinePictureWithMask

I’ve got one email where all attached images are inverted.

The original image:

After resize and reorient:

The files are garden variety jpg files. How can I fix the problem?

Maybe there is an ICC Profile, which is not applied?

CombinePictureWithMask reads pixels directly.

e.g. what happens if you export to JPEG from GraphicsMagick and read with Picture.Open?

How can I see if there is an ICC profile?

What do you mean with “export to JPEG from GraphicsMagick and read with Picture.Open”? The data comes from emails and is fed into html. There are no files and no picture.

Let GraphicsMagick write out the picture to a file, so you can inspect it with other application like Graphics Converter.
ICC Profile is available via iccColorProfile property.

The exported file looks okay:test

What does this tell me?

What does Graphics Converter tell you?
Is it CMYK image? Or maybe has an ICC Profile inverting colors?

Graphic Converter tells me that I have a CMYK image:

I only know that RGB is for screens and CMYK is for printing. The documentation on ICC profiles in Graphics Magick only says “use a blob”.

CombinePictureWithMask can’t work on a CMYK picture.
You may first change type to RGB.


image.type = TrueColorType

which may do the conversion.

Hat geklappt!

1 Like