Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected output of make_blob with format keyword if opened by read #594

Closed
multiSnow opened this issue Sep 27, 2022 · 3 comments
Closed

Comments

@multiSnow
Copy link

multiSnow commented Sep 27, 2022

This is the script:

from wand.image import Image

with Image(filename='test.png',format='PNG') as im:
    print('open by class',im.make_blob(format='RGBA')[:20])

with Image() as im:
    im.read(filename='test.png',format='PNG')
    print('open by read',im.make_blob(format='RGBA')[:20])

generate test.png by this command line:

magick -size 128x128 xc:white test.png

Result of the script:

open by class b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
open by read b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x80'

The 'open by class' is expected.

wand version: 0.6.10
ImageMagick version: 7.1.0-50
system version: Linux 5.19.0-1-amd64 Debian 5.19.6-1

Update:
Remove the 'format' keyword in read() may fix provide expected result, but this keyword is required for loading APNG format using blob or file keyword.

Similar problem also happened with JPEG format, cause the solution in #593 (comment) not work correctly.

Update:
A simpler script to show this problem:

from wand.image import Image

with Image() as im:
    im.read(filename='test.png',format='PNG')
    with im.convert('RGBA') as converted:
        print('before make_blob:',converted.format)
        converted.make_blob()
        print('after make_blob:',converted.format)
@emcconville
Copy link
Owner

Thanks for reporting this. Looks like something changes in IM-7. I would suspect it's related to the difference between MagickSetFormat vs MagickSetImageFormat. If true, should be a quick fix.

emcconville added a commit that referenced this issue Sep 28, 2022
@emcconville
Copy link
Owner

Possible fix with 7fbf296. Feel free to test it out.

@multiSnow
Copy link
Author

Possible fix with 7fbf296. Feel free to test it out.

Confirmed with ImageMagick 7.1.0-50.
Thanks.

emcconville added a commit that referenced this issue Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants