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

CalledProcessError saving icns file to io.BytesIO() #4732

Closed
jeffre opened this issue Jun 26, 2020 · 2 comments · Fixed by #4741
Closed

CalledProcessError saving icns file to io.BytesIO() #4732

jeffre opened this issue Jun 26, 2020 · 2 comments · Fixed by #4741
Labels
Bug Any unexpected behavior, until confirmed feature.

Comments

@jeffre
Copy link

jeffre commented Jun 26, 2020

Currently, writing an icns file to an io.ByteIO object fails. This operation is supported by other filetypes (jpg, png, ico, etc) so I'm not clear if this report falls under feature request or bug

What did you do?

Write icns file to io.BytesIO() object

from PIL import Image
import io
import base64

im = Image.new(mode="RGBA", size=(256,256), color=(0,100,246,255))
f = io.BytesIO()
im.save(fp=f, format="icns")

b64 = base64.b64encode(f.getvalue()).decode()
print(f'Image: {b64}')

What did you expect to happen?

Fill the io.BytesIO object

What actually happened?

macOS's iconutil failed because it was provided an empty filename for output (-o)

subprocess.CalledProcessError: Command '['iconutil', '-c', 'icns', '-o', '', '/var/folders/91/q75bkgks1196cr1rsr0399540000gn/T/tmppmsm3z2y.iconset']' returned non-zero exit status 1.

I believe one solution would be if filename variable is empty then use a dummy name and after popen returns, read the file from disk.

What are your OS, Python and Pillow versions?

  • OS: macOS Mojave 10.14.6
  • Python: 3.7.7
  • Pillow: 7.1.2
@nulano
Copy link
Contributor

nulano commented Jun 26, 2020

This would be fixed by merging #4526.

@radarhere
Copy link
Member

I've created #4741 to fix this, in case it makes it in before #4526.

@radarhere radarhere added the Bug Any unexpected behavior, until confirmed feature. label Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants