Page 1 of 1
Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 4:55 am
by Googie85
Hi Guys!!!
I am trying to rotate an image 270 Degrees and then save the image back to an image file. The code is:
Code: Select all
on mouseDown
set the visible of image "TEST" to true
put the screenrect into blah
put specialFolderPath("documents") & slash & "Nav.jpg" into GEST
export snapshot from rect blah to file GEST as JPEG
put "binfile:"&GEST into POL
put URL POL into image "TEST"
set the angle of image "TEST" to 270
//SAVE IMAGE CODE HERE
put specialFolderPath("documents") & slash & "NavYY.jpg" into GEST1
put "binfile:"&GEST1 into HYU
export image "TEST" to URL HYU
//
set the URL of widget "Browser" to GEST1
end mouseDown
The resulting file (export image "TEST" to URL HYU) turns out to be a 6.5MB file that is corrupted and cannot be viewed. Is there a simpler way to rotate an image file that I am missing?
Many Thanks,
Googie.
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 9:18 am
by richmond62
-
Code: Select all
on mouseUp
answer file "Select image:"
if the result is not cancel then
import paint from file it
set the name of the last control to "XYZ"
end if
set the left of img "XYZ" to 10
clone img "XYZ"
set the name of the last control to "XXX"
set the loc of img "XXX" to 600,200
set the angle of img "XXX" to 270
----
ask file "Choose where you wish to save your image"if the result = "cancel"
then exit mouseUp
else
export snapshot from img "XXX" to file it & ".png" as PNG
end if
delete img "XYZ"
delete img "XXX"
end mouseUp
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 9:26 am
by Googie85
I have no problem rotating the image, rather, saving the image to a .jpg or .png .
Any ideas?
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 9:30 am
by richmond62
Try the stack I have just uploaded: that will save PNG images.
-
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 12:26 pm
by jmburnod
Hi,
You maybe have to add "as PNG" or "as JPG" after this line
export image "TEST" to URL HYU
Beat regards
Jean-Marc
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 2:33 pm
by richmond62
The whole problem probably has got to do with NOT being allowed to export
images on Android.
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 6:06 pm
by stam
richmond62 wrote: ↑Fri Sep 16, 2022 2:33 pm
The whole problem probably has got to do with NOT being allowed to export
images on Android.
Is that really the case? A quick glance at the code above suggest that Googie85 is trying to save to specialFolderPath("documents") which should be doable on mobile? (unless it isn't permitted to save files to the
sandboxed Documents folder on Android?).
I wonder if it's not the export that is failing but the 'set the URL' statement sent to the browser widget (last line)?
Dictionary for Browser Widget wrote:In particular, file: URLs must be of the form file://absolute path, and the path should be URL-encoded.
As far as i can tell the URL to the browser widget is passed in format
specialFolderPath("documents") & slash & "<filename>" which a) will miss the "file://" bit and b) won't be URL-encoded...
HTH
S.
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 6:08 pm
by jacque
richmond62 wrote: ↑Fri Sep 16, 2022 2:33 pm
The whole problem probably has got to do with NOT being allowed to export
images on Android.
That's news to both me and the documentation. I think Jean-Marc identified the problem. The docs say:
Code: Select all
If you don't specify a format, the file is exported as PBM, PGM, or PPM.
I think those formats are old. Specifying an image format will produce a more modern and compact image file.
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 8:24 pm
by richmond62
PBM: Perfect Bowel Movement . . .
I wonder if anyone remembers those image formats.
I remember learning about JPG in 1993.
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 8:42 pm
by Klaus
richmond62 wrote: ↑Fri Sep 16, 2022 8:24 pm
I wonder if anyone remembers those image formats.
I do!
I learned to know these formats from Metacard in 1992.
Never heard of them before and actually never after that.
I thinke these are pixel formats from the UNIX "stone age".
Re: Rotating And Saving An Image.
Posted: Fri Sep 16, 2022 8:54 pm
by richmond62
Yes, they are mentioned in the RunRev version 1 dictionary.