get the width and height of an image file all types
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
get the width and height of an image file all types
Hi All,
We have a function that return the width and height of a .png file.
http://forums.runrev.com/phpBB2/viewtop ... =8&t=12386
What about other types (jpg,tiff etc..) ?
Can we use the same way and what is the magic string to search ?
Best regards
Jean-Marc
We have a function that return the width and height of a .png file.
http://forums.runrev.com/phpBB2/viewtop ... =8&t=12386
What about other types (jpg,tiff etc..) ?
Can we use the same way and what is the magic string to search ?
Best regards
Jean-Marc
https://alternatic.ch
Re: get the width and height of an image file all types
Hi Jean-Marc,
You can use ImageMagick.
Kind regards,
Mark
You can use ImageMagick.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: get the width and height of an image file all types
Hi Mark,
Do you think imagemagik's library using by LiveCode ?
Kind regards
Jean-Marc
Do you think imagemagik's library using by LiveCode ?
Kind regards
Jean-Marc
https://alternatic.ch
Re: get the width and height of an image file all types
Hi Jean-Marc,
I'm not sure what you mean, but I use ImageMagick with LiveCode (sometimes).
Kind regards,
Mark
I'm not sure what you mean, but I use ImageMagick with LiveCode (sometimes).
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: get the width and height of an image file all types
The method that converts the binary header info will of course require a different script for each image format, but if you're not too concerned about performance the method that loads the image and obtains the formattedWidth and formattedHeight of the image object will work easily with all image formats LiveCode supports.jmburnod wrote:Hi All,
We have a function that return the width and height of a .png file.
http://forums.runrev.com/phpBB2/viewtop ... =8&t=12386
What about other types (jpg,tiff etc..) ?
Can we use the same way and what is the magic string to search ?
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
Re: get the width and height of an image file all types
FourthWorld wrote:
For 100 files .png
• Shell: 614 ticks
• set the filename: 42 ticks (with lockscreen)
• reading binary: 2 ticks
reading binary
12 ticks for 4792 image files
27 ticks for 7385 image files
Yes. Performance was the goal. "reading binary" is the fastestif you're not too concerned about performance the method that loads the image and obtains the formattedWidth and formattedHeight of the image object will work easily with all image formats LiveCode supports.
For 100 files .png
• Shell: 614 ticks
• set the filename: 42 ticks (with lockscreen)
• reading binary: 2 ticks
reading binary
12 ticks for 4792 image files
27 ticks for 7385 image files
https://alternatic.ch
Re: get the width and height of an image file all types
Hi,
I don't think there is a way to load TIFF images in LiveCode yet (which Jean-Marc asks about). You'll need a different solution for that and ImageMagick is just the thing.
Best,
Mark
I don't think there is a way to load TIFF images in LiveCode yet (which Jean-Marc asks about). You'll need a different solution for that and ImageMagick is just the thing.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: get the width and height of an image file all types
Hi Mark,
I read the doc about imagemagic but i dont understand how can i use it with LiveCode.
I'll download it and i'm coming back
Kind regards
Jean-marc
I read the doc about imagemagic but i dont understand how can i use it with LiveCode.

I'll download it and i'm coming back
Kind regards
Jean-marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: get the width and height of an image file all types
What shell command are you using for that?jmburnod wrote:For 100 files .png
• Shell: 614 ticks
• set the filename: 42 ticks (with lockscreen)
• reading binary: 2 ticks
reading binary
12 ticks for 4792 image files
27 ticks for 7385 image files
Also, FWIW LiveCode supports millisecond timing, helpful for smaller measurements.
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
Re: get the width and height of an image file all types
FourthWorld wrote:
What shell command are you using for that?
Code: Select all
on mouseUp
answer file "Bild laden.../Load image..."
put QUOTE & it & QUOTE into bild
## Get ehight of image:
get shell("sips -g pixelHeight" && bild)
## It is the last word
put last word of it into hoch
## Same for width:
get shell("sips -g pixelWidth" && bild)
put last word of it into breit
put breit & "," & hoch into fld 1
end mouseUp
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: get the width and height of an image file all types
Thanks for that. I've not had occasion to use sips, but it seems worth knowing about.
If you wan to read the binary header info of any file format, the process would be the same as for PNG: you'll have to find the file format spec and parse it up, using LiveCode's binaryConvert function to translate values from the binary form into decimal for use in your scripts.
This will no doubt be tedious (somewhat more so with JPEG and TIFF than GIF, since those have variable resolutions), but doable.
If you wan to read the binary header info of any file format, the process would be the same as for PNG: you'll have to find the file format spec and parse it up, using LiveCode's binaryConvert function to translate values from the binary form into decimal for use in your scripts.
This will no doubt be tedious (somewhat more so with JPEG and TIFF than GIF, since those have variable resolutions), but doable.
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
Re: get the width and height of an image file all types
Welcome.Thanks for that.
Me too before Klaus posted itI've not had occasion to use sips, but it seems worth knowing about.
https://alternatic.ch
Re: get the width and height of an image file all types
Hi friends,
if QuickTIme is installed on the target machines, you could use a (QuickTIme) player object
to check all QT comaptible image file tpyes like TIFF, PSD etc..., too!
Just set the filename and check formattedwidth and formattedheight of the player.
With a "lock screen" this is as fast as using an image object in Livecode for JPG and PNG!
Best
Klaus
if QuickTIme is installed on the target machines, you could use a (QuickTIme) player object
to check all QT comaptible image file tpyes like TIFF, PSD etc..., too!
Just set the filename and check formattedwidth and formattedheight of the player.
With a "lock screen" this is as fast as using an image object in Livecode for JPG and PNG!
Best
Klaus