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

Draw on a ico file without having to convert to png #3875

Closed
MagTun opened this issue May 28, 2019 · 3 comments · Fixed by #3897
Closed

Draw on a ico file without having to convert to png #3875

MagTun opened this issue May 28, 2019 · 3 comments · Fixed by #3897
Projects

Comments

@MagTun
Copy link

MagTun commented May 28, 2019

What did you do?

Load an ico image, draw lines and save it.

What did you expect to happen?

I expect to get lines on the .ico image

What actually happened?

No lines

The solution

I have to load the .ico image, save it as a png , reload the png and finally draw the line on the png.

Feature request

That would be nice to be able to draw line on .ico files or if it's not possible to implement this workaround on the "back side"

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.6
  • Pillow: 5.1.0
from PIL import Image, ImageDraw,ImageFont

#create an ico file: this step is just for debug, I already have a `ico` file
img = Image.new('RGB', (50, 50), (125, 167, 242)) 
img.save('a1.ico')  

#code start here
im = Image.open('a1.ico').save('a1.png')
im = Image.open('a1.png')
d = ImageDraw.Draw(im)
d.line((0, 0) + im.size, fill=128)
d.line((0, im.size[1], im.size[0], 0), fill=128)
im.save('pil_modif.ico')  
@radarhere
Copy link
Member

Thanks for reporting this problem. For your immediate use until this is resolved, I can suggest using im.copy() instead of needing to save it and then load it again -

from PIL import Image, ImageDraw,ImageFont

#create an ico file: this step is just for debug, I already have a `ico` file
img = Image.new('RGB', (50, 50), (125, 167, 242)) 
img.save('a1.ico')  

#code start here
im = Image.open('a1.ico')
im = im.copy()
d = ImageDraw.Draw(im)
d.line((0, 0) + im.size, fill=128)
d.line((0, im.size[1], im.size[0], 0), fill=128)
im.save('pil_modif.ico')

@radarhere radarhere added this to In progress in Pillow May 29, 2019
@MagTun
Copy link
Author

MagTun commented May 29, 2019

Thanks a lot, this is a better way of doing it!

@radarhere
Copy link
Member

I've created PR #3897 to resolve this.

@radarhere radarhere moved this from In progress to Review/QA in Pillow Jun 10, 2019
Pillow automation moved this from Review/QA to Closed Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

3 participants