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

API to export image to PNG #3

Open
develar opened this issue Mar 14, 2016 · 12 comments
Open

API to export image to PNG #3

develar opened this issue Mar 14, 2016 · 12 comments

Comments

@develar
Copy link

develar commented Mar 14, 2016

I tried (to simplify, I merged #2 into my fork) and icns.js can read ICNS file.

But how I can export image to PNG? Required image not in the PNG format, so, it is a bit tricky ;)

I want a simple API like: export(size, pngFilePath).

@sonnyp
Copy link
Owner

sonnyp commented Mar 14, 2016

icns encapsulates different type of images, mostly png though.

In pratice you cannot be sure you'll get a png out of an icns so some conversion logic must be added to handle that case with imagemagick or whatever.

I don't think the conversation part belongs to this project but I wanted to make a icns2png cli using icns.js ...

If you simply want to get a png out of a icns file on OS X maybe you should use https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/iconutil.1.html ? Not sure if it's available on barebone OS X or with xcode / xcode cli though

@develar
Copy link
Author

develar commented Mar 14, 2016

I cannot use iconutil because Linux should be supported.

I don't think the conversation belongs to this project.

Hmm... If I am not wrong, formats are specified in the ICNS spec, so, my expectation that module will not only just read images list, but will also support extraction.

Ok, thanks for clarification. I will try to fix it in my fork.

@sonnyp
Copy link
Owner

sonnyp commented Mar 14, 2016

I cannot use iconutil because Linux should be supported.

Oh, that's why I made icns.js

Hmm... If I am not wrong, formats are specified in the ICNS spec, so, my expectation that module will not only just read images list, but will also support extraction.

Yes png is part of formats supported by icns but icns doesn't say your file MUST contain a png buffer. I found OS X default applications without png for example. That's why conversion is required if you want something reliable.

Ok, thanks for clarification. I will try to fix it in my fork.

If you want I can have a look tonight or tomorrow and see what I can come up with

@sonnyp
Copy link
Owner

sonnyp commented Mar 14, 2016

BTW and out of curiosity can you elaborate on the use case?

@develar
Copy link
Author

develar commented Mar 14, 2016

can you elaborate on the use case

Please see electron-userland/electron-builder#239 (comment)

In short: electron-builder converts OS X icns to linux icon set to build deb package. To simplify developer life.

@sonnyp
Copy link
Owner

sonnyp commented Mar 14, 2016

Ok so you need multiple sizes.

So basically the utility would have to extract png from the provided icns, if a png is missing for a size get a png of higher size and scale down. If no png is suitable, get a file of different format and convert.

Altough I'm not sure to understand why you need icns2png rather than png2icns, if you're building a cross platform solution wouldn't it be easier for the user and electron-builder to let the user provide a png of high resolution and build a icns based on that file?

@sonnyp
Copy link
Owner

sonnyp commented Mar 14, 2016

If you like the user provided png file approach I'd be happy to contribute to electron-build as my company uses it. https://redbooth.com/desktop-app

@sonnyp
Copy link
Owner

sonnyp commented Mar 14, 2016

icns.js lacks the ability to build icns file but I wanted to implemented that anyway and it's easy

@develar
Copy link
Author

develar commented Mar 14, 2016

Sorry for misunderstanding, I need exactly export icns to pngs files. Not png2icns, but icns2png.

Use case: user is already provide icns. I don't want to require yet another icon set for Linux. I want to convert existing icns file to png files on the fly.

as my company uses it

Nice to hear it :)

wouldn't it be easier for the user and electron-builder to let the user provide a png of high resolution and build a icns based on that file

  • Maybe, but currently windows requires only one ico file.
  • And there are tools to make icns.
  • And OS X in most cases will be more popular/important target than Linux.
  • Linux support was added last.

So, maybe it is only for me, but I decided to make icns the primary format.

@sonnyp
Copy link
Owner

sonnyp commented Mar 14, 2016

Maybe, but currently windows requires only one ico file.

png to ico is easy, how do you handle windows at the moment? icns to ico?

And there are tools to make icns.
And OS X in most cases will be more popular/important target than Linux.

true

Okay I guess icns should be a first class citizen, adding png support later would be awesome though as electron-builder would take care of creating the icns and wouln't have to build it myself but yes let's start with correct icns support. I'll merge my PRs, and see what I can come up with.

@develar
Copy link
Author

develar commented Mar 14, 2016

how do you handle windows at the moment? icns to ico?

We require ico file explicitly :) (https://github.com/loopline-systems/electron-builder#in-short "and icon.ico (Windows app icon)") For the same reasons as in my previous comment.

@sonnyp
Copy link
Owner

sonnyp commented Mar 14, 2016

So user must provide a ico and icns files.

IMHO it really all comes down to the scope of electron-builder.
Either electron-builder doesn't take care of icons at all and users must provide files for Windows/Linux/OS X OR electron builder accept a png (or SVG or whatever) file and spit a good/valid icon file for each platform.

For my use case I prefer the second solution because cross-platform application icon is more complicated than it looks like.

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