Camera photos deformed ?

Hi,

I’m using the media.capturePhoto in my app, but some behaviours are really strange :

  • On Mac Simulator, all my square photos will be saved in 640x480, and thus are stretched.

  • On iPhone5 (we currently can only test on this kind of device), all our photos are saved in landscape. In fact all photos took in landscape mode are good, but all photos took in portrait are rotated… it is a real trouble for us because we’re planning to allow an user to crop its photo, but it would look really weird if we’d display its photo rotated.
    Edit : after testing on and iPad mini, we got the same result, photos are still saved in landscape.

Does anyone ever met this problem and/or have an idea how to solve it ? We’re using Corona build 2189, and here is my function call :
 

media.capturePhoto( {
  listener = photoTook,
  destination = {baseDir=system.TemporaryDirectory, filename = scene.avatarID … “.png”, type=“image”}
} )

// The listener only do print() now, I erased anything else to see if anything changed, but nothing.

This problem can be really serious for some developers, I’d be surprised nobody would have anything to say about it…

Hi @corona7219,

I’m not sure what you mean by “saved in landscape”. It looks like you’re saving to the temporary directory, not displaying the photo to the screen. Do you mean they appear in landscape when you (in some other code) load the same file from the temporary directory and place it on screen?

Thanks,

Brent

Hi Brent, thanks for the attention !

It’s as you said : when I visualize my photo with a simple display.newImage() it’s shown in landscape mode (even when the photo was taken in portrait by the user).

Hi @corona7219,

Can you please post the contents of your config.lua? Specifically the “content” table and sub-tables.

Thanks,

Brent

Our config.lua is really close from what you can find in the http://coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/ tutorial. For iPhone5, it’s :
 

if ( string.sub( system.getInfo(“model”), 1, 2 ) == “iP” and display.pixelHeight > 960 ) then

  application =

  {

    content =

    {

      width = 320,

      height = 568,

      scale = “letterBox”,

      xAlign = “center”,

      yAlign = “center”,

      fps = 60,

      imageSuffix =

      {

        ["@2x"] = 1.2,

      },

    }

  }

Hi @corona7219,

Thanks for the update. Can I also see what you’ve put in your “build.settings” file? Specifically the “orientation” table (but go ahead and paste the entire thing, so I can make sure there’s no table nesting issues).

Thanks,

Brent

That’s no problem, here’s our build.settings (as you can see, our app only does show in portrait mode) :

settings = {

    orientation = {

        default = “portrait”,

        supported = { “portrait”, }

    },

    

    iphone = {

        plist = {

            UIStatusBarHidden = true,

            UIPrerenderedIcon = true,

            

            UIAppFonts =

            {

                “FUTURAH.TTF”

            },

            

            FacebookAppID = “XXXXXXXXX”,

            CFBundleURLTypes =

            {

                {

                    CFBundleURLSchemes =

                    {

                        “fbXXXXXXXXX”,

                    }

                }

            }

        }

    },

    

    plugins =

    {

        [“facebook”] =

        {

            publisherId = “com.coronalabs”,

            supportedPlatforms = { iphone=true, [“iphone-sim”]=true },

        },
 

        [“plugin.openssl”] =

        {

                – required

                publisherId = “com.coronalabs”,

        },

    }

}

Yes, the simulator using the iSight camera does produce a 640x480 from what should be a square photo.  I’m not sure this is something that Engineering will want to pursue, since we are building mobile apps and not OS-X apps.

However the other issue, I can’t reproduce.  Using an iPhone 5 (iOS 7.1.2) and the code from the media.capturePhoto() doc page and a portrait based app, I got a portrait oriented photo.

I would suggest that you put together a minimal project complete with a build.settings and config.lua and let us take a look at the code and see if we can figure out how it differs from what I tried.

Rob

I just created a minimal project working the same way as our app do (2 scenes, a media.capturePhoto, and a display.newImage), you’ll find it here : https://www.dropbox.com/s/1yj3xtlke5jzprl/TakePhoto.zip

I tested it on an iPod Touch (iOs 6) and an iPhone 5 (iOs 7.1.1), both have the same result as our app do (photos are in landscape, even if you take them in portrait).

Well you have found a very interesting bug…   .png files are rotated weirdly.   .jpg files are rotated correctly.

With  your sample app, please file a bug report using the “Report a Bug” feature above and make sure to note that JPEGs work but PNG’s do not.

Rob

This problem can be really serious for some developers, I’d be surprised nobody would have anything to say about it…

Hi @corona7219,

I’m not sure what you mean by “saved in landscape”. It looks like you’re saving to the temporary directory, not displaying the photo to the screen. Do you mean they appear in landscape when you (in some other code) load the same file from the temporary directory and place it on screen?

Thanks,

Brent

Hi Brent, thanks for the attention !

It’s as you said : when I visualize my photo with a simple display.newImage() it’s shown in landscape mode (even when the photo was taken in portrait by the user).

Hi @corona7219,

Can you please post the contents of your config.lua? Specifically the “content” table and sub-tables.

Thanks,

Brent

Our config.lua is really close from what you can find in the http://coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/ tutorial. For iPhone5, it’s :
 

if ( string.sub( system.getInfo(“model”), 1, 2 ) == “iP” and display.pixelHeight > 960 ) then

  application =

  {

    content =

    {

      width = 320,

      height = 568,

      scale = “letterBox”,

      xAlign = “center”,

      yAlign = “center”,

      fps = 60,

      imageSuffix =

      {

        ["@2x"] = 1.2,

      },

    }

  }

Hi @corona7219,

Thanks for the update. Can I also see what you’ve put in your “build.settings” file? Specifically the “orientation” table (but go ahead and paste the entire thing, so I can make sure there’s no table nesting issues).

Thanks,

Brent

That’s no problem, here’s our build.settings (as you can see, our app only does show in portrait mode) :

settings = {

    orientation = {

        default = “portrait”,

        supported = { “portrait”, }

    },

    

    iphone = {

        plist = {

            UIStatusBarHidden = true,

            UIPrerenderedIcon = true,

            

            UIAppFonts =

            {

                “FUTURAH.TTF”

            },

            

            FacebookAppID = “XXXXXXXXX”,

            CFBundleURLTypes =

            {

                {

                    CFBundleURLSchemes =

                    {

                        “fbXXXXXXXXX”,

                    }

                }

            }

        }

    },

    

    plugins =

    {

        [“facebook”] =

        {

            publisherId = “com.coronalabs”,

            supportedPlatforms = { iphone=true, [“iphone-sim”]=true },

        },
 

        [“plugin.openssl”] =

        {

                – required

                publisherId = “com.coronalabs”,

        },

    }

}

Yes, the simulator using the iSight camera does produce a 640x480 from what should be a square photo.  I’m not sure this is something that Engineering will want to pursue, since we are building mobile apps and not OS-X apps.

However the other issue, I can’t reproduce.  Using an iPhone 5 (iOS 7.1.2) and the code from the media.capturePhoto() doc page and a portrait based app, I got a portrait oriented photo.

I would suggest that you put together a minimal project complete with a build.settings and config.lua and let us take a look at the code and see if we can figure out how it differs from what I tried.

Rob

I just created a minimal project working the same way as our app do (2 scenes, a media.capturePhoto, and a display.newImage), you’ll find it here : https://www.dropbox.com/s/1yj3xtlke5jzprl/TakePhoto.zip

I tested it on an iPod Touch (iOs 6) and an iPhone 5 (iOs 7.1.1), both have the same result as our app do (photos are in landscape, even if you take them in portrait).