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 I'm working on so it would need to have some open 
source license.

Cheers

Monte
--
Monte Goulding

M E R Goulding - software development services
mergExt - There's an external for that!





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


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
  return jpg
   else if byteToNum(char 1 of pData) is 137 and  byteToNum(char 2 of pData) is 
80 and \
 byteToNum(char 1 of pData) is 78 and  byteToNum(char 2 of pData) is 71 
then
  return png
   else if byteToNum(char 1 of pData) is 46 and  byteToNum(char 2 of pData) is 
77 then
  return bmp
   else
  return image
   end if
end imageDataExtension

On 23/02/2013, at 7:40 AM, Monte Goulding mo...@sweattechnologies.com wrote:

 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 I'm working on so it would need to have some open 
 source license.
 
 Cheers
 
 Monte
 --
 Monte Goulding
 
 M E R Goulding - software development services
 mergExt - There's an external for that!
 
 
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode

--
Monte Goulding

M E R Goulding - software development services
mergExt - There's an external for that!





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


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
cause subtle changes in how an image is displayed.  But this is true for
the many apps that save/display PNGs, as well as LC, so it may not be an
issue.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX Design




On 2/22/13 12:40 PM, Monte Goulding mo...@sweattechnologies.com wrote:

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 I'm working on so it would need to have some
open source license.

Cheers

Monte
--
Monte Goulding

M E R Goulding - software development services
mergExt - There's an external for that!





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode




___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


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 each object will be represented by a folder and while most 
properties will be exported as JSON I thought there are some properties that 
would be better as separate files. The script is the prime example but an image 
is another one. Also I'm considering the htmlText of a field may be worthwhile 
as a separate property although that could get quite complicated for unshared 
text in shared groups so might be best avoided.


On 23/02/2013, at 8:22 AM, Scott Rossi sc...@tactilemedia.com wrote:

 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
 cause subtle changes in how an image is displayed.  But this is true for
 the many apps that save/display PNGs, as well as LC, so it may not be an
 issue.

--
Monte Goulding

M E R Goulding - software development services
mergExt - There's an external for that!





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


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.
 
 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 each object will be represented by a folder and while most 
 properties will be exported as JSON I thought there are some properties that 
 would be better as separate files. The script is the prime example but an 
 image is another one. Also I'm considering the htmlText of a field may be 
 worthwhile as a separate property although that could get quite complicated 
 for unshared text in shared groups so might be best avoided.
 
 
 On 23/02/2013, at 8:22 AM, Scott Rossi sc...@tactilemedia.com wrote:
 
 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
 cause subtle changes in how an image is displayed.  But this is true for
 the many apps that save/display PNGs, as well as LC, so it may not be an
 issue.
 
 --
 Monte Goulding
 
 M E R Goulding - software development services
 mergExt - There's an external for that!
 
 
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode

--
Monte Goulding

M E R Goulding - software development services
mergExt - There's an external for that!





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


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 issue as long as you start with best resizeQuality.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX Design




On 2/22/13 1:37 PM, 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.

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 each object will be represented by a folder and while
most properties will be exported as JSON I thought there are some
properties that would be better as separate files. The script is the
prime example but an image is another one. Also I'm considering the
htmlText of a field may be worthwhile as a separate property although
that could get quite complicated for unshared text in shared groups so
might be best avoided.


On 23/02/2013, at 8:22 AM, Scott Rossi sc...@tactilemedia.com wrote:

 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
 cause subtle changes in how an image is displayed.  But this is true for
 the many apps that save/display PNGs, as well as LC, so it may not be an
 issue.

--
Monte Goulding

M E R Goulding - software development services
mergExt - There's an external for that!





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode




___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


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 to save the reformatted image data, so recompressing JPEG shouldn't
 be an issue as long as you start with best resizeQuality.


This is for a stackFile export/import script for VCS support. I was exporting 
imageData ad alphaData but then I realised that the text of the image covers 
both so why not just use that. All the other properties are stored too so it's 
up to the user to set the resizeQuality which as it turns out is YANPNITPA !!!

--
Monte Goulding

M E R Goulding - software development services
mergExt - There's an external for that!





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


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 the bug I found recently, 
it affects re-storing the patterns of a control when re-storing all of the 
properties from an array. More info; 
http://quality.runrev.com/show_bug.cgi?id=10683

Mark assures me the issue is fixed for the next release, but it may throw a 
spanner in the works if you come across the same issue for your tests with the 
current LC builds, i.e. 5.5.4 or 6.0.0-dp4 so I just thought I'd mention it in 
case this saves you some hassle.

Paul
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


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 issue but thanks for the heads 
up.

Cheers

Monte
On 23/02/2013, at 11:18 AM, Paul Hibbert l...@pbh.on-rev.com wrote:

 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 the bug I 
 found recently, it affects re-storing the patterns of a control when 
 re-storing all of the properties from an array. More info; 
 http://quality.runrev.com/show_bug.cgi?id=10683
 
 Mark assures me the issue is fixed for the next release, but it may throw a 
 spanner in the works if you come across the same issue for your tests with 
 the current LC builds, i.e. 5.5.4 or 6.0.0-dp4 so I just thought I'd mention 
 it in case this saves you some hassle.

--
Monte Goulding

M E R Goulding - software development services
mergExt - There's an external for that!





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode