Exported images growing in size
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Exported images growing in size
Windows 7 & Livecode 7.0.6
I have a stack with a single card on it, and a single button on the card. The script of the button is -
on mouseUp
Import paint from file "Map.jpg"
Export last image to file "MapAfterImport.jpg" as JPEG
end mouseUp
There is no other script in the stack. The original Map.jpg file is 8Mb. When I press the button, Livecode writes a MapAfterImport.jpg file onto my desktop - which is 22Mb.
I'd appreciate any info on why importing and exporting a file would treble its size, and what I can do to avoid this happening.
Thanks in advance
I have a stack with a single card on it, and a single button on the card. The script of the button is -
on mouseUp
Import paint from file "Map.jpg"
Export last image to file "MapAfterImport.jpg" as JPEG
end mouseUp
There is no other script in the stack. The original Map.jpg file is 8Mb. When I press the button, Livecode writes a MapAfterImport.jpg file onto my desktop - which is 22Mb.
I'd appreciate any info on why importing and exporting a file would treble its size, and what I can do to avoid this happening.
Thanks in advance
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Exported images growing in size
Hi Kim,
This is the same with OSX.
You can get the text of image and export it like this :
Best regards
Jean-Marc
This is the same with OSX.
You can get the text of image and export it like this :
Code: Select all
put the text of last img into tDataImg
put tDataImg into url("binfile:" & "MapAfterImport.jpg")
Jean-Marc
https://alternatic.ch
Re: Exported images growing in size
Hi Kim,
1. welcome to the forum!
2. you could "play around" with the JPEGQualtity (0 - 100) before exporting.
...
set the JPEGQuality to 50
export last image to file "MapAfterImport.jpg" as JPEG
...
Best
Klaus
1. welcome to the forum!
2. you could "play around" with the JPEGQualtity (0 - 100) before exporting.
...
set the JPEGQuality to 50
export last image to file "MapAfterImport.jpg" as JPEG
...
Best
Klaus
Re: Exported images growing in size
Thanks Jean-Marc & Klaus
I got Jean-Marc's suggestion to work immediately, so I didn't try Klaus's (although I'll store it away for future use).
While I have some people who know what they are doing listening, can I ask another question?
I'm trying to copy an image, to the same location (card or group), but assign the copy a new name. I need to do this because I want to edit the copy while retaining the original.
I have this working, but intuitively my solution seems too complicated
- copy the image into a temp location
- (re)name the version of the image that is in the temp location
- copy the renamed image back into the original location
- delete the contents of the image in the temp location
It works, but I hate it.
I also played around with a solution using "last image" but couldn't get that to work.
What is the simplest way to create a copy of an image, where the copy has a new name, in the same card/group as the original image?
Regards
I got Jean-Marc's suggestion to work immediately, so I didn't try Klaus's (although I'll store it away for future use).
While I have some people who know what they are doing listening, can I ask another question?
I'm trying to copy an image, to the same location (card or group), but assign the copy a new name. I need to do this because I want to edit the copy while retaining the original.
I have this working, but intuitively my solution seems too complicated
- copy the image into a temp location
- (re)name the version of the image that is in the temp location
- copy the renamed image back into the original location
- delete the contents of the image in the temp location
It works, but I hate it.
I also played around with a solution using "last image" but couldn't get that to work.
What is the simplest way to create a copy of an image, where the copy has a new name, in the same card/group as the original image?
Regards
Re: Exported images growing in size
Hi Kim,
just made a quick test and this worked fine (copy image to same card)
You may want to take a look at these great example/learning stacks:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
just made a quick test and this worked fine (copy image to same card)
Code: Select all
on mouseUp
copy img "old image" to this cd
set the name of last img to "new image"
end mouseUp
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
Re: Exported images growing in size
Thanks Klaus
I'll play around with that
Regards
I'll play around with that
Regards
Re: Exported images growing in size
Hi Kim,
another way is to directly copy the image on the disk!
No need to import and export again:
...
put url("binfile:Map.jpg") into url("binfile:MapWithoutImport.jpg")
...
Done
Make sure the image is in the current DEFAULTFOLDER.
Best
Klaus
another way is to directly copy the image on the disk!
No need to import and export again:
...
put url("binfile:Map.jpg") into url("binfile:MapWithoutImport.jpg")
...
Done
Make sure the image is in the current DEFAULTFOLDER.
Best
Klaus
Re: Exported images growing in size
Hi Klaus
Sorry if this is a dumb question, but when should I use Binfile and when should I use File? Aren't all files stored on computers "binary"? By way of a note - I trained & worked as a programmer a long time ago, then got out of it. I've missed everything that has happened in programming since Back to the Future part II
Regards
Sorry if this is a dumb question, but when should I use Binfile and when should I use File? Aren't all files stored on computers "binary"? By way of a note - I trained & worked as a programmer a long time ago, then got out of it. I've missed everything that has happened in programming since Back to the Future part II
Regards
Re: Exported images growing in size
By default, LiveCode will represent file content as text, and helpfully interpret line endings according to the platform. So on Windows you will get crlf inserted/ converted when saving to a file. This helps readability and transportability cross-platform, but will obviously break a file with content that is not human-readable, such as a jpeg image or audio file. In those cases using "binfile" will preserve the file contents faithfully, without interpretation of any line ending bytes in the file, since they aren't typically line ending markers.
Not a dumb question at all
Not a dumb question at all
Re: Exported images growing in size
Thanks. That has cleared up one of the things that was confusing me