export snapshot at DPI
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark
export snapshot at DPI
Hi
I'm looking at adding `at DPI` to the export snapshot command. At least for JPEG and PNG. Any naysayers?
Cheers
Monte
I'm looking at adding `at DPI` to the export snapshot command. At least for JPEG and PNG. Any naysayers?
Cheers
Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- VIP Livecode Opensource Backer
- Posts: 9867
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: export snapshot at DPI
I like it!
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Livecode Opensource Backer
- Posts: 9476
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: export snapshot at DPI
That would be wonderful; after all a "jobbing screenshot one can e-mail to Granny" does
not need to be of the same sort of quality as other screenshots; and the old size versus quality
thing is always there; with a DPI feature one could play around until one got
exactly what one required.
not need to be of the same sort of quality as other screenshots; and the old size versus quality
thing is always there; with a DPI feature one could play around until one got
exactly what one required.
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: export snapshot at DPI
@monte - I believe the name should probably be PPI. Take a look at this:
http://en.wikipedia.org/wiki/Pixel_density
@richmond - I don't think it would work quite like you expect. The pixel density information in an image (ppi) tells the application displaying the image how many pixels should fit within an inch. For LiveCode this becomes especially relevant with support for high resolution displays and the new import snapshot ... at size option.
For example, to get all of pixel information on a 300x300 area of a retina laptop screen into an image in LiveCode I have to import a rectangle that is 300,300 by I have to specify the size as 600x600. This gives me a 600x600 image in LiveCode with all of the data that the retina display is displaying (twice as many pixels). The problem is that the image is supposed to be displayed at 300x300 in order to look right to the end user.
This is where PPI comes in. If the PPI settings in the metadata of the image specify 144 and the image was made on a Mac then we know that there is twice as much image data and the image should be displayed at half the actual size (normal PPI is 72 for Mac).
So this setting won't really help you fiddle with file size and quality.
http://en.wikipedia.org/wiki/Pixel_density
@richmond - I don't think it would work quite like you expect. The pixel density information in an image (ppi) tells the application displaying the image how many pixels should fit within an inch. For LiveCode this becomes especially relevant with support for high resolution displays and the new import snapshot ... at size option.
For example, to get all of pixel information on a 300x300 area of a retina laptop screen into an image in LiveCode I have to import a rectangle that is 300,300 by I have to specify the size as 600x600. This gives me a 600x600 image in LiveCode with all of the data that the retina display is displaying (twice as many pixels). The problem is that the image is supposed to be displayed at 300x300 in order to look right to the end user.
This is where PPI comes in. If the PPI settings in the metadata of the image specify 144 and the image was made on a Mac then we know that there is twice as much image data and the image should be displayed at half the actual size (normal PPI is 72 for Mac).
So this setting won't really help you fiddle with file size and quality.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: export snapshot at DPI
@trevordevore I'm happy with PPI or perhaps we should just use `at density` and document that density is an integer value of pixels per inch? I'll take this opportunity to remind everyone that the metric system is much more logical
The other thing I guess is what to do when combining at density with at size. Should the size continue to be raw pixels or should the density be factored into the size. If the density is factored in then in your example you could export snapshot at density 144 at size 300,300 and the engine would then create a 600,600 image with the correct density info. However this really means we need to factor in the screen density and maybe the scaling of the stack so KISS principles would leave the size being raw pixels I think...
The other thing I guess is what to do when combining at density with at size. Should the size continue to be raw pixels or should the density be factored into the size. If the density is factored in then in your example you could export snapshot at density 144 at size 300,300 and the engine would then create a 600,600 image with the correct density info. However this really means we need to factor in the screen density and maybe the scaling of the stack so KISS principles would leave the size being raw pixels I think...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: export snapshot at DPI
I guess density should permit either with or at to aid readability when combining with at size?
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: export snapshot at DPI
I think that would be fine.monte wrote:@trevordevore I'm happy with PPI or perhaps we should just use `at density` and document that density is an integer value of pixels per inch?
You'll hear no argument from me.monte wrote:I'll take this opportunity to remind everyone that the metric system is much more logical
This is the tricky part. My understanding is that images captured on Mac are 72 PPI. Images captured on Windows are 96 PPI. On a retina Mac the PPI is 144. On Windows zoomed to 150% the PPI is 144. Now sometimes people capture images but assign different PPI settings to the image. I've seen mention of this for people using images for print.monte wrote:The other thing I guess is what to do when combining at density with at size. Should the size continue to be raw pixels or should the density be factored into the size. If the density is factored in then in your example you could export snapshot at density 144 at size 300,300 and the engine would then create a 600,600 image with the correct density info. However this really means we need to factor in the screen density and maybe the scaling of the stack so KISS principles would leave the size being raw pixels I think...
I think the size should be raw pixels. The developer specifies what the density is and the density can be determined by using the screenpixelscale and a hardcoded value based on platform.
I think 'with density' is easier to read when combined with 'at size'.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: export snapshot at DPI
@trevordevore just emailed me suggesting perhaps changing the concept to `with metadata <metadata array>` so it's easier to add other metadata later without adding syntax. Seems a good idea to me unless there isn't anything else we want to add in which case it would be annoying having to create the array... Thoughts?
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: export snapshot at DPI
OK I have implemented this here:
https://github.com/montegoulding/liveco ... e_metadata
If there's no issues I'll go ahead and document and send a pull request. It's forked of develop because of the hassle of building master on Mavericks.
The syntax is:
Where theMetadataA is an array with a key "density" and a value in pixels per inch.
https://github.com/montegoulding/liveco ... e_metadata
If there's no issues I'll go ahead and document and send a pull request. It's forked of develop because of the hassle of building master on Mavericks.
The syntax is:
Code: Select all
export snapshot ([from rect[angle] rectangle] of object ... | [from object] ) [(with | without) effects] [(and | with) metadata theMetadataA ] [at size width, height] to {file filePath | container} [as format] [with mask maskFile]
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: export snapshot at DPI
@monte: Great monte - thanks for this... Trevor's been asking for it for a while
I think an array is the best way forward - it will allow us to extend it in the future to support insertion of EXIF fields into generated images which I'm sure could be useful at some point. Only one suggestion, I wonder whether the syntax should be:
My rationale here is that going from left to right the parameters go from being related to the region of the object, then whether it should include layer properties (effects), then what size to scale it to, then things that are related to the output file - i.e. they go from rendering related concerns to file format related concerns.
I think an array is the best way forward - it will allow us to extend it in the future to support insertion of EXIF fields into generated images which I'm sure could be useful at some point. Only one suggestion, I wonder whether the syntax should be:
Code: Select all
export ... [with / without effects ] [ at size width, height ] [ with metadata <metadata> ]
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: export snapshot at DPI
I think having the metadata array last makes sense cognitively as well.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: export snapshot at DPI
Sure I'll change that then document
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: export snapshot at DPI
OK, so here's the pull request: https://github.com/runrev/livecode/pull/900
900 pull requests! That's not a bad run rate!
After changing the syntax to where you wanted I realised I could move the code outside the snapshot specific stuff so now it works with all the export commands. I also found that export <format> wasn't setting the format so I resolved that. I suspect that's rarely used because it relies on the selected object rather than specifying an image but it might as well work I searched for export in the bug database and couldn't find it reported.
900 pull requests! That's not a bad run rate!
After changing the syntax to where you wanted I realised I could move the code outside the snapshot specific stuff so now it works with all the export commands. I also found that export <format> wasn't setting the format so I resolved that. I suspect that's rarely used because it relies on the selected object rather than specifying an image but it might as well work I searched for export in the bug database and couldn't find it reported.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: export snapshot at DPI
@monte: I pulled this into develop today so it will be in 6.7 - I made a few minor changes for expediency (Trevor asked for it asap, and we're hoping to do a build tomorrow). The changes are mainly to make it easier for the 7.0 guys to merge in the new feature. Thanks again!
Re: export snapshot at DPI
Howdy
I've implemented a read only metadata array property for images however there's a couple of points I need clarification on:
- There's some rounding error with PNGs and at the moment the density is a double. So you could export with a DPI of 144 and after import it might be 143.932 or something... anyway should I round it?
- The current P_METADATA obviously isn't in the array section of the Properties enum so I'm not sure what that might break... it looks like some stuff in externalv1 mostly... what would you like me to do there?
- It's a very different property than the field chunk property so should it have a completely separate doc?
I've implemented a read only metadata array property for images however there's a couple of points I need clarification on:
- There's some rounding error with PNGs and at the moment the density is a double. So you could export with a DPI of 144 and after import it might be 143.932 or something... anyway should I round it?
- The current P_METADATA obviously isn't in the array section of the Properties enum so I'm not sure what that might break... it looks like some stuff in externalv1 mostly... what would you like me to do there?
- It's a very different property than the field chunk property so should it have a completely separate doc?
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/