Closed igr closed 7 years ago
Sounds like a good idea, though I'd have to think of the right CLI interface, since right now it's pngpaste thefile.png
, so perhaps pngpaste --auto-detect-extension thefile
or pngpaste -a thefile
? Either way, I can try to incorporate any format detection code this week if you have any contributions there.
You might even skip autodetection for now - just use the target extension, i.e.:
pngpaste foo.png // will copy PNG
pngpaste bar.jpg // will copy JPEG
I am not osx dev, but looking the code, can you simply replace png
with jpeg
and make it work ;)))?
Yeah true, that's much simpler, though would pngpaste
be responsible for performing a conversion?
I'll take a look this week and update this issue.
Thank you! what conversion? you mean from png to jpg, or? Would it be possible that when I copy a jpg file (like from webpage), simply store that content in a file, without any conversion?
what conversion? you mean from png to jpg, or? Would it be possible that when I copy a jpg file (like from webpage), simply store that content in a file, without any conversion?
Yeah, I mean if the user has copied a JPEG, but tries pngpaste some.png
, or the user has copied a PNG, but tries pngpaste some.jpg
.
Got it. Well, for the first version you can just throw an error; if conversion is too much work :)
I would not expect from your tool to do conversion, that might be out of scope, and conversions may be complex. I would rather work on autodetection so when you don't specify the extension:
pngpaste foo
it will detect the right pic format and store it in eg foo.jpg
or foo.png
or foo.tiff
:)
So unfortunately I dug into it and AppKit's API doesn't expose the original source's format. It just comes back as a "bitmap" and there's no clear enum or string that indicates whether the source was a JPEG, a PNG, a GIF, etc.
Thus, #9 does allow for pngpaste foo.jpg
but there's no auto-detection of the actual source. This is the data structure provided - https://developer.apple.com/reference/appkit/nsbitmapformat?language=objc - and it is not quite helpful in the detection endeavor.
Going ahead and closing this.
Would it be possible to make it format agnostic? e.g. to detect JPG and store as JPG... I would not like to clone just to make a jpg version of it; would it be cool to have it all in one. wdyt?