Imported vs. referenced images - performance benefit?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

Imported vs. referenced images - performance benefit?

Post by Ledigimate » Mon Feb 20, 2017 2:59 pm

Dear LiveCoders,

I have an app that makes extensive use of imported images in its user interface. Something I've noticed is that my stack's file size is quite big. I know I can decrease the file size by using referenced images in stead of imported images, but before I embark on the cumbersome task of converting all the images to referenced ones, I just need to know one thing -- is there any performance benefit to using imported images as opposed to using referenced images? Because if there is, I would rather have a faster bloated stack than a slower lean stack.

Any advice on this would be much appreciated.

Regards

Gerrie
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Imported vs. referenced images - performance benefit?

Post by jmburnod » Mon Feb 20, 2017 5:04 pm

Hi Gerrie,
I think that depends how many and what kind of images you will use.
I one of my app I choosed referenced images for 3500 small img with an average size 50k, but all images of interface are no referenced images because they are used as icon.
Of course if you have a short collection of large images no-referenced is maybe the best ways
Test the speed of these two options in your context is probably the "meta best way".
Best regards
Jean-Marc
https://alternatic.ch

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

Re: Imported vs. referenced images - performance benefit?

Post by Ledigimate » Mon Feb 20, 2017 6:18 pm

I need to find a way to automate the image conversion process, because I would hate having to convert each image by hand, one-by-one.

If there's anyone out there who has had to do this before, and you can provide a conversion script I can use, I would appreciate that so much. In the mean time, I'll try to write my own conversion script and see how far I get.

Thanks
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Imported vs. referenced images - performance benefit?

Post by jmburnod » Mon Feb 20, 2017 6:53 pm

This script export each image of one cd to a folder myFolderImg of the documents folder
and sets the filename of each image too.
Be careful.This script export image with the current rect. If you have resized your images you have to use formattedWidth/height to export it with original rect.

Code: Select all

on doMyExportImgOfCd
   put specialfolderPath("documents") & "/" & "myFolderImg" into tPathFolderD
   if there is not a folder tPathFolderD then
      new folder tPathFolderD
   end if
   put the num of imgs of this cd into tNbImg
   repeat with i = 1 to tNbImg
      if the text of img i <> empty then
         put the short name of img i into tNameImg
         put tPathFolderD & "/" & tNameImg & ".png"  into tPathFile
         export img i to file tPathFile  as PNG
         wait 1 milliseconds
         set the filename of img i to tPathFile
      end if
   end repeat
end doMyExportImgOfCd
https://alternatic.ch

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

Re: Imported vs. referenced images - performance benefit?

Post by Ledigimate » Tue Feb 21, 2017 6:27 pm

Thank you so much Jean-Marc, :D you've saved me a lot of work!

I'll adapt your script for my stack and I will let you know how my stack performs after the images has been converted.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Imported vs. referenced images - performance benefit?

Post by jmburnod » Tue Feb 21, 2017 7:19 pm

Hi,
I forgot to write that you can do inverse (referenced to no referenced) with almost the same script :D
Jean-Marc
https://alternatic.ch

Post Reply