get type from the text of image

2013-02-22 Thread Monte Goulding
Hi Has anyone got a handler that works out the image type from the text of the image. I want to save the text of an image but I want to do so with the correct extension. I don't want to use the export command because of the risk of some quality loss from the image. This is for the VCS stuff

Re: get type from the text of image

2013-02-22 Thread Monte Goulding
OK.. came up with the following based on a StackOverflow answer on doing this in C. Anyone have anything better?: function imageDataExtension pData if char 1 to 4 of pData is GIF8 then return gif else if byteToNum(char 1 of pData) is 255 and byteToNum(char 2 of pData) is 216 then

Re: get type from the text of image

2013-02-22 Thread Scott Rossi
Hi Monte: You can probably use the paintCompression property to check the image type. It might also help to know that PNG is essentially lossless -- you shouldn't lose any image data using this format. You may find that dealing with the gamma of PNG images is something of a black art and can

Re: get type from the text of image

2013-02-22 Thread Monte Goulding
Ah... the paintCompression might be sufficient to use as an extension. It's not perfect but it will probably do. Basically if someone imported a JPG I didn't think it would be suitable for the VCS to export/import as png. If you say it would be ok then I'll run with that. What I'm doing is

Re: get type from the text of image

2013-02-22 Thread Monte Goulding
It turns out the paintCompression is yet another property not in the properties array (YAPNITPA)... On 23/02/2013, at 8:37 AM, Monte Goulding mo...@sweattechnologies.com wrote: Ah... the paintCompression might be sufficient to use as an extension. It's not perfect but it will probably do.

Re: get type from the text of image

2013-02-22 Thread Scott Rossi
Not sure about your setup, but I imagine you could store binary image data so you don't have to mess with image format all. The one complication is if you allow folks to scale an image in whatever you're doing. You'll need to save the reformatted image data, so recompressing JPEG shouldn't be an

Re: get type from the text of image

2013-02-22 Thread Monte Goulding
On 23/02/2013, at 9:08 AM, Scott Rossi sc...@tactilemedia.com wrote: Not sure about your setup, but I imagine you could store binary image data so you don't have to mess with image format all. The one complication is if you allow folks to scale an image in whatever you're doing. You'll need

Re: get type from the text of image

2013-02-22 Thread Paul Hibbert
On 2013-02-22, at 2:05 PM, Monte Goulding wrote: It turns out the paintCompression is yet another property not in the properties array (YAPNITPA)... Monte, If you are using the properties of an object stored in an array for rebuilding a stack in your VCS, you probably should be aware of

Re: get type from the text of image

2013-02-22 Thread Monte Goulding
Thanks Paul For readability of the properties file I have moved the colors and patterns to their named individual counterparts rather than the list you get in the properties array. Otherwise in a text diff it's unclear exactly which property changed. So I don't think my code will have this