issue with saving a photo from the Device's photo library

Hello, i am trying to save a photo from  android photo library to the system.DocumentsDirectory but i have a problem. Although i get succesfuly the pic from the library, the pic is not in it’s real resolution. Actualy the pic is cutted.  I believe this has to do with display.save() function that i use.  How can i save the photo without to be cutted or scaled? Any help would be appreciated!

this is my code:

local function sessionComplete ( event ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t = event.target &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local baseDir = system.DocumentsDirectory &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; display.save(t, "photo.jpg", baseDir) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.x = \_W/2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.y = \_H/2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.xScale = .25 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.yScale = .25 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; local options = &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; to = { "email@email.com" }, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; subject = "My High Score", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; isBodyHtml = true, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; body = "\<html\>\<body\>I scored over \<b\>9000\</b\>!!! Can you do better?\</body\>\</html\>", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; attachment = &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; { baseDir=system.DocumentsDirectory, filename="photo.jpg", type="image" }, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;native.showPopup("mail", options) &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; end &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; local UploadBar = display.newImageRect("m1.png",144,60); &nbsp;&nbsp; &nbsp;UploadBar:setReferencePoint(display.TopLeftReferencePoint) &nbsp;&nbsp; &nbsp;UploadBar.x=0; &nbsp;&nbsp; &nbsp;UploadBar.y=0; &nbsp;&nbsp;&nbsp; local function newphoto ( event ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (event.phase == "began") then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media.show( media.PhotoLibrary, sessionComplete ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; end &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; UploadBar:addEventListener("touch", newphoto) &nbsp;

I believe you need to use the media.save() function. 

I’m having the same problem. Previously I was able to use the media.save() function to save the photo immediately after I took it, and it would save the photo with whatever file name I put into that function (media.save(“filename.jpg”, [directory])). However, this doesn’t work anymore. 

A work around might be to display the photo in full resolution, use display.save(), then resize the photo.

EDIT: This doesn’t work, either. If the photo is larger than the screen, display.save() only saves the portion that is shown on the screen, not the portion that is off the screen.

Hi @aaron34,

When you say that “media.save” worked before, was this on iOS or Android? Can I see the code you’re using? I can hopefully help you when I have more information. 

Thanks,

Brent Sorrentino

My app worked for both iOS and Android.

[lua]local sessionComplete = function(event)

    image = event.target

    media.save(“recentphoto.jpg”, baseDir)

end

if media.hasSource(media.Camera) then

    media.show(media.Camera, sessionComplete)

else[/lua]

is essentially what I had. I’m more interested in finding a way to save the photo, or at least get the file path of the photo so that I can manipulate it in its full resolution. What I’m eventually doing is attaching the photo to an email, so I need the file name. Without it I can’t. 

I believe you need to use the media.save() function. 

I’m having the same problem. Previously I was able to use the media.save() function to save the photo immediately after I took it, and it would save the photo with whatever file name I put into that function (media.save(“filename.jpg”, [directory])). However, this doesn’t work anymore. 

A work around might be to display the photo in full resolution, use display.save(), then resize the photo.

EDIT: This doesn’t work, either. If the photo is larger than the screen, display.save() only saves the portion that is shown on the screen, not the portion that is off the screen.

Hi @aaron34,

When you say that “media.save” worked before, was this on iOS or Android? Can I see the code you’re using? I can hopefully help you when I have more information. 

Thanks,

Brent Sorrentino

My app worked for both iOS and Android.

[lua]local sessionComplete = function(event)

    image = event.target

    media.save(“recentphoto.jpg”, baseDir)

end

if media.hasSource(media.Camera) then

    media.show(media.Camera, sessionComplete)

else[/lua]

is essentially what I had. I’m more interested in finding a way to save the photo, or at least get the file path of the photo so that I can manipulate it in its full resolution. What I’m eventually doing is attaching the photo to an email, so I need the file name. Without it I can’t.