Page 1 of 1

Image URL produces Zero file size.

Posted: Fri May 23, 2008 1:17 pm
by reelstuff
I have an interesting issue here with loading an image from the users hard drive.

Code: Select all

on mouseUp
get folderPath1
set the itemdelimiter to "/"
put "/images/" after the last item of it
  put it into fld testing2
put it into fPath
if there is not a folder fPath then create folder fPath
  set the filetype to ""
put fld "Field_image_name" into myVar
put (fPath & myVar) into myimageVar
--to check and see if the file path exists correctly
put myimageVar into fld testing4
--everything works to this point, I have an image displayed on a card
--I have the path to that image, Now I just need to put that image into 
--the fPath so far my attempts have failed to produce a result.
--the following line produces the everything correctly but the image contents
--is zero  

put image "iData" into URL ("binfile:" & myimageVar)
I am using the following script to get the image file, this may be where the problem exists.

Code: Select all

function GetFileData pPrompt, pMacType, pWinType, pTextOrBinary 
 if pPrompt is empty then put "Select a file:" into pPrompt 
 if the platform is "MacOS" then 
   answer file pPrompt of type pMacType 
  else 
   answer file pPrompt with filter pWinType 
  end if
  if it is empty then exit to top 
 set the filename of img "iData" to it
 -- test to see what the output is 
 put it into fld "var2"
 end GetFileData 
I have an empty image called iData this script gets the image and displays the image correctly
however, the file size shows as zero.

Which I think is why the above script to save the image on the users hard drive fails to produce a file size.

I have no idea why this happens, if anyone has a suggestion or a Tip, let me know.


Thanks

Tim

after further experimentation

Posted: Fri May 23, 2008 5:22 pm
by reelstuff
I now have a file, that contains, some text, further evidence of a malfunction on the users part,

But I did find this,


As an update, I found the following in the Docs,
Important! Don't use the URL keyword when specifying an imageURL. The imageSource of a character is a file location (or image ID or name), not the image data itself. If you use the URL keyword, the imageSource property is set to the contents of the URL, not the URL itself, and this is usually not what's wanted.
which indicates why the file is either empty or populated with the url to the image.

However, no alternative is offered in the documentation, it just states, dont use the URL keyword but gives no solution to the issue raised.

Anyone have any thoughts about this?

Posted: Fri May 23, 2008 6:23 pm
by BvG
I have no idea why you'd want to do that, but "put image xyz" will never give you anything meaningfull, when said image is a referenced image. Seting the filename means it's referenced. So depending on what you want to do:

Use the simplified noncompressed rev-internal image binary representation:

put the imagedata of image "iData" into URL ("binfile:" & myimageVar)

most likely you want to copy the file, or post the binary data of the original file to some url:

revcopyfile field "var2", myImageVar
or
put url ("binfile:" & field "var2") into url ("binfile:" & myimageVar)

Posted: Fri May 23, 2008 6:37 pm
by reelstuff
BvG wrote:I have no idea why you'd want to do that, but "put image xyz" will never give you anything meaningfull, when said image is a referenced image. Seting the filename means it's referenced. So depending on what you want to do:

Use the simplified noncompressed rev-internal image binary representation:

put the imagedata of image "iData" into URL ("binfile:" & myimageVar)

most likely you want to copy the file, or post the binary data of the original file to some url:

revcopyfile field "var2", myImageVar
or
put url ("binfile:" & field "var2") into url ("binfile:" & myimageVar)
Thanks for your answer, I believe I can work with that, actually I wanted the user to pick an image file from their hard drive, than put that image into a specific place on the users hard drive, (all without asking where to save the file, ect, so the file goes right where it is needed)

Sorry I did not get a chance to talk before I had to leave, my allergies were terrible, if you remember the friday afternoon, it got to the point that I could no longer deal with the allergy issues, so I went back to the hotel.

did you stay for the saturday session?

Tim