Understanding Image Sizes, Before And Display

Sannyasin Brahmanathaswami brahma at hindu.org
Sat Dec 22 19:55:43 EST 2018


I found way; it seems convoluted to me. I create an image, store in width/height to a field....

on mouseup. 
# on palette/ utilities stack/ for some reason selectedImage()  won't work
	
	try
     		 put the long id of the selectedObject into sImage 
      	end try
   if sImage is empty then
      Answer "You need to select an image" with "OK"
      exit to top
   end if
   put the long id of the selectedObject into sImage
   
   if fld "DefaultImagePath" is empty then  put the long id of the selectedObject into sImage
   if fld "DefaultImagePath" is empty then 
      answer file "Select the image you wish to view:" with type "JPEG Images|jpg|JPEG"
      if it is "Cancel" then
         exit to top
      else
         put it into tFilename
         put  tFilename into fld "DefaultImagePath"
         create image 
         put it into tNewImage
         set the loc of tnewImage to -1000,-1000
         set the filename tnewImage to tFileName
         set the filename of sImage to fld "DefaultImagePath"
         put (the width of  tnewImage)& comma & (the height of tnewImage)into field "originalSize"
         delete tNewImage
      end if
   else
      set width of sImage  to item 1 of field  "originalSize"
      set height of sImage  to item 2 of field  "originalSize"
      
   end if
   
end mouseup

Brahmanathaswami
 
BS  wrote:

    Well after all these years, I want to know the original width and height of a referenced image by its "content" and not by its "image data" which will change if the image was resized. So let's say it is referenced brand new image:  
    
    answer file "Select the image you wish to view:" with type "JPEG Images|jpg|JPEG"
    
    # the filename of an image to that. Let say its 250 X 150 pixels 
    # resize this image  to something "stupid" like 100 x100
    
    How does one query, at that point in time, the original height and width?
    
    I looked through to dictionary, and don't see a way.  In course of the mini-study I found "prepare"
    
    on mouseup
          answer file "Select the image you wish to view:" with type "JPEG Images|jpg|JPEG"
          if it is "Cancel" then
             exit to top
          else
             put it into tFileName
          end if
          prepare image file tFileName
          put the width of image file tFilename  # error here
    end mouseup
    
    This entry seems a little lean.... 
    
    prepare 
    
    "...Then access the image and display it as needed on your stack. Since the image is already cached into memory, it displays instantly."
    
    One would think that since it is cached, you can get its rect?
    
    What am missing? Do have to create a new image to get its original size?
    
    ===========
    
    The location and name of the image file you want to load and
    decompress into the image data cache. Since the image data cache is 
    keyed on the absolute filename, any images which reference that file
    are able to use the data from the cache. This assumes that the cache has
    not been flushed.
    
    Description
    Use the prepare image command to speed up execution when 
    showing image data.
    
    Use the prepare image command to preload an image at some time 
    before it is needed. Then access the image and display it as needed on 
    your stack. Since the image is already cached into memory, it displays 
    instantly.
    
    
    
    
    
    
    
    _______________________________________________
    use-livecode mailing list
    use-livecode at lists.runrev.com
    Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
    http://lists.runrev.com/mailman/listinfo/use-livecode
    



More information about the use-livecode mailing list