You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Durham (Created) (JIRA)" <ji...@apache.org> on 2012/01/19 03:30:39 UTC

[jira] [Created] (CB-183) ios camera targetWidth/Height don't match the documentation

ios camera targetWidth/Height don't match the documentation
-----------------------------------------------------------

                 Key: CB-183
                 URL: https://issues.apache.org/jira/browse/CB-183
             Project: Apache Callback
          Issue Type: Bug
          Components: iOS
    Affects Versions: 1.0.0
            Reporter: Durham
            Assignee: Shazron Abdullah


According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions] using targetWidth and targetHeight should maintain the aspect ratio of the original photo . The ios implementation does not do this. Instead it makes the shortest side match the desired target, and crops the rest.

For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024, it results in a 1024x1024 square picture with the excess removed. On android it results in something like 1024x640, and nothing is cropped.

I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m imageByScalingAndCroppingForSize. This is based off the android implementation.

{code:title=Camera.m}
...
if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
{
    CGFloat newRatio = targetWidth / targetHeight;
    CGFloat origRatio = width / height;

    if (origRatio > newRatio) 
    {
        targetHeight = (targetWidth * height) / width
    } 
    else 
    {
        targetWidth = (targetHeight * width) / height;
    }
}

CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
UIGraphicsBeginImageContext(finalSize);

CGRect thumbnailRect = CGRectZero;
thumbnailRect.size.width  = targetWidth;
thumbnailRect.size.height = targetHeight;

[sourceImage drawInRect:thumbnailRect];
...
{code}

I'm currently seeing the problem in 1.0, but from looking at the code it still looks like a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CB-183) ios camera targetWidth/Height don't match the documentation

Posted by "Brian LeRoux (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brian LeRoux updated CB-183:
----------------------------

    Fix Version/s:     (was: 1.6.0)
                   1.7.0
    
> ios camera targetWidth/Height don't match the documentation
> -----------------------------------------------------------
>
>                 Key: CB-183
>                 URL: https://issues.apache.org/jira/browse/CB-183
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 1.0.0
>            Reporter: Durham
>            Assignee: Shazron Abdullah
>             Fix For: 1.7.0
>
>
> According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions] using targetWidth and targetHeight should maintain the aspect ratio of the original photo . The ios implementation does not do this. Instead it makes the shortest side match the desired target, and crops the rest.
> For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024, it results in a 1024x1024 square picture with the excess removed. On android it results in something like 1024x640, and nothing is cropped.
> I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m imageByScalingAndCroppingForSize. This is based off the android implementation.
> {code:title=Camera.m}
> ...
> if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
> {
>     CGFloat newRatio = targetWidth / targetHeight;
>     CGFloat origRatio = width / height;
>     if (origRatio > newRatio) 
>     {
>         targetHeight = (targetWidth * height) / width
>     } 
>     else 
>     {
>         targetWidth = (targetHeight * width) / height;
>     }
> }
> CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
> UIGraphicsBeginImageContext(finalSize);
> CGRect thumbnailRect = CGRectZero;
> thumbnailRect.size.width  = targetWidth;
> thumbnailRect.size.height = targetHeight;
> [sourceImage drawInRect:thumbnailRect];
> ...
> {code}
> I'm currently seeing the problem in 1.0, but from looking at the code it still looks like a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CB-183) ios camera targetWidth/Height don't match the documentation

Posted by "Shazron Abdullah (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shazron Abdullah updated CB-183:
--------------------------------

    Fix Version/s:     (was: 1.6.1)
                   1.7.0
    
> ios camera targetWidth/Height don't match the documentation
> -----------------------------------------------------------
>
>                 Key: CB-183
>                 URL: https://issues.apache.org/jira/browse/CB-183
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 1.0.0
>            Reporter: Durham
>            Assignee: Shazron Abdullah
>             Fix For: 1.7.0
>
>
> According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions] using targetWidth and targetHeight should maintain the aspect ratio of the original photo . The ios implementation does not do this. Instead it makes the shortest side match the desired target, and crops the rest.
> For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024, it results in a 1024x1024 square picture with the excess removed. On android it results in something like 1024x640, and nothing is cropped.
> I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m imageByScalingAndCroppingForSize. This is based off the android implementation.
> {code:title=Camera.m}
> ...
> if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
> {
>     CGFloat newRatio = targetWidth / targetHeight;
>     CGFloat origRatio = width / height;
>     if (origRatio > newRatio) 
>     {
>         targetHeight = (targetWidth * height) / width
>     } 
>     else 
>     {
>         targetWidth = (targetHeight * width) / height;
>     }
> }
> CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
> UIGraphicsBeginImageContext(finalSize);
> CGRect thumbnailRect = CGRectZero;
> thumbnailRect.size.width  = targetWidth;
> thumbnailRect.size.height = targetHeight;
> [sourceImage drawInRect:thumbnailRect];
> ...
> {code}
> I'm currently seeing the problem in 1.0, but from looking at the code it still looks like a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CB-183) ios camera targetWidth/Height don't match the documentation

Posted by "Shazron Abdullah (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shazron Abdullah updated CB-183:
--------------------------------

    Fix Version/s:     (was: 1.7.0)
                   1.6.1
    
> ios camera targetWidth/Height don't match the documentation
> -----------------------------------------------------------
>
>                 Key: CB-183
>                 URL: https://issues.apache.org/jira/browse/CB-183
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 1.0.0
>            Reporter: Durham
>            Assignee: Shazron Abdullah
>             Fix For: 1.6.1
>
>
> According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions] using targetWidth and targetHeight should maintain the aspect ratio of the original photo . The ios implementation does not do this. Instead it makes the shortest side match the desired target, and crops the rest.
> For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024, it results in a 1024x1024 square picture with the excess removed. On android it results in something like 1024x640, and nothing is cropped.
> I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m imageByScalingAndCroppingForSize. This is based off the android implementation.
> {code:title=Camera.m}
> ...
> if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
> {
>     CGFloat newRatio = targetWidth / targetHeight;
>     CGFloat origRatio = width / height;
>     if (origRatio > newRatio) 
>     {
>         targetHeight = (targetWidth * height) / width
>     } 
>     else 
>     {
>         targetWidth = (targetHeight * width) / height;
>     }
> }
> CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
> UIGraphicsBeginImageContext(finalSize);
> CGRect thumbnailRect = CGRectZero;
> thumbnailRect.size.width  = targetWidth;
> thumbnailRect.size.height = targetHeight;
> [sourceImage drawInRect:thumbnailRect];
> ...
> {code}
> I'm currently seeing the problem in 1.0, but from looking at the code it still looks like a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (CB-183) ios camera targetWidth/Height don't match the documentation

Posted by "Volker Schuchardt (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13226086#comment-13226086 ] 

Volker Schuchardt edited comment on CB-183 at 3/15/12 9:23 AM:
---------------------------------------------------------------

Hi Shazron Abdullah,

I found the same issue in version 1.4. Therefore I changed the code to match the aspect ratio as follows in file 'Camera.m':

(UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize
{
    ...
    CGPoint thumbnailPoint = CGPointMake(0.0,0.0);
    
    if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
    {
        CGFloat widthFactor = targetWidth / width;
        CGFloat heightFactor = targetHeight / height;

        if (widthFactor > heightFactor) 
//here the value was widthFactor but has to be heightFactor. So I changed it.
            scaleFactor = heightFactor; // scale to fit height
        else
//Here the value was heightFactor but has to be widthFactor. So I changed it.
            scaleFactor = widthFactor; // scale to fit width

        scaledWidth  = width * scaleFactor;
        scaledHeight = height * scaleFactor;
		
        // center the image
        if (widthFactor > heightFactor)
        {
            thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5; 
        }
        else 
            if (widthFactor < heightFactor)
            {
                thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
            }
    }       

//This line was added to replace the one below. There we won't crop the picture, but just resize it to the new calculated values.
    UIGraphicsBeginImageContext(CGSizeMake(scaledWidth, scaledHeight));
//    UIGraphicsBeginImageContext(targetSize); // this will crop
    
    ...
}

Hope it helps.
Best regards,
Volker
                
      was (Author: forestvogo):
    Hi Shazron Abdullah,

I found the same issue in version 1.4. Therefore I changed the code to match the aspect ratio as follows in file 'Camera.m':

(UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize
{
    ...
//Added the following line to save the resized messures at a later point.
    CGSize scaledSize = CGSizeMake(0, 0); 
    CGPoint thumbnailPoint = CGPointMake(0.0,0.0);
    
    if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
    {
        CGFloat widthFactor = targetWidth / width;
        CGFloat heightFactor = targetHeight / height;

        if (widthFactor > heightFactor) 
//here the value was widthFactor but has to be heightFactor. So I changed it.
            scaleFactor = heightFactor; // scale to fit height
        else
//Here the value was heightFactor but has to be widthFactor. So I changed it.
            scaleFactor = widthFactor; // scale to fit width

        scaledWidth  = width * scaleFactor;
        scaledHeight = height * scaleFactor;
//This line was added to save the new width and height values.
        scaledSize = CGSizeMake(scaledWidth, scaledHeight); 
		
        // center the image
        if (widthFactor > heightFactor)
        {
            thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5; 
        }
        else 
            if (widthFactor < heightFactor)
            {
                thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
            }
    }       

//This line was added to replace the one below. There we won't crop the picture, but just resize it to the new calculated values.
    UIGraphicsBeginImageContext(scaledSize);
//    UIGraphicsBeginImageContext(targetSize); // this will crop
    
    ...
}

Hope it helps.
Best regards,
Volker
                  
> ios camera targetWidth/Height don't match the documentation
> -----------------------------------------------------------
>
>                 Key: CB-183
>                 URL: https://issues.apache.org/jira/browse/CB-183
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 1.0.0
>            Reporter: Durham
>            Assignee: Shazron Abdullah
>             Fix For: 1.6.0
>
>
> According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions] using targetWidth and targetHeight should maintain the aspect ratio of the original photo . The ios implementation does not do this. Instead it makes the shortest side match the desired target, and crops the rest.
> For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024, it results in a 1024x1024 square picture with the excess removed. On android it results in something like 1024x640, and nothing is cropped.
> I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m imageByScalingAndCroppingForSize. This is based off the android implementation.
> {code:title=Camera.m}
> ...
> if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
> {
>     CGFloat newRatio = targetWidth / targetHeight;
>     CGFloat origRatio = width / height;
>     if (origRatio > newRatio) 
>     {
>         targetHeight = (targetWidth * height) / width
>     } 
>     else 
>     {
>         targetWidth = (targetHeight * width) / height;
>     }
> }
> CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
> UIGraphicsBeginImageContext(finalSize);
> CGRect thumbnailRect = CGRectZero;
> thumbnailRect.size.width  = targetWidth;
> thumbnailRect.size.height = targetHeight;
> [sourceImage drawInRect:thumbnailRect];
> ...
> {code}
> I'm currently seeing the problem in 1.0, but from looking at the code it still looks like a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CB-183) ios camera targetWidth/Height don't match the documentation

Posted by "Shazron Abdullah (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shazron Abdullah updated CB-183:
--------------------------------

    Fix Version/s: 1.6.0

Need verification.
                
> ios camera targetWidth/Height don't match the documentation
> -----------------------------------------------------------
>
>                 Key: CB-183
>                 URL: https://issues.apache.org/jira/browse/CB-183
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 1.0.0
>            Reporter: Durham
>            Assignee: Shazron Abdullah
>             Fix For: 1.6.0
>
>
> According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions] using targetWidth and targetHeight should maintain the aspect ratio of the original photo . The ios implementation does not do this. Instead it makes the shortest side match the desired target, and crops the rest.
> For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024, it results in a 1024x1024 square picture with the excess removed. On android it results in something like 1024x640, and nothing is cropped.
> I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m imageByScalingAndCroppingForSize. This is based off the android implementation.
> {code:title=Camera.m}
> ...
> if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
> {
>     CGFloat newRatio = targetWidth / targetHeight;
>     CGFloat origRatio = width / height;
>     if (origRatio > newRatio) 
>     {
>         targetHeight = (targetWidth * height) / width
>     } 
>     else 
>     {
>         targetWidth = (targetHeight * width) / height;
>     }
> }
> CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
> UIGraphicsBeginImageContext(finalSize);
> CGRect thumbnailRect = CGRectZero;
> thumbnailRect.size.width  = targetWidth;
> thumbnailRect.size.height = targetHeight;
> [sourceImage drawInRect:thumbnailRect];
> ...
> {code}
> I'm currently seeing the problem in 1.0, but from looking at the code it still looks like a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CB-183) ios camera targetWidth/Height don't match the documentation

Posted by "Volker Schuchardt (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13226086#comment-13226086 ] 

Volker Schuchardt commented on CB-183:
--------------------------------------

Hi Shazron Abdullah,

I found the same issue in version 1.4. Therefore I changed the code to match the aspect ratio as follows in file 'Camera.m':

(UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize
{
    ...
//Added the following line to save the resized messures at a later point.
    CGSize scaledSize = CGSizeMake(0, 0); 
    CGPoint thumbnailPoint = CGPointMake(0.0,0.0);
    
    if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
    {
        CGFloat widthFactor = targetWidth / width;
        CGFloat heightFactor = targetHeight / height;

        if (widthFactor > heightFactor) 
//here the value was widthFactor but has to be heightFactor. So I changed it.
            scaleFactor = heightFactor; // scale to fit height
        else
//Here the value was heightFactor but has to be widthFactor. So I changed it.
            scaleFactor = widthFactor; // scale to fit width

        scaledWidth  = width * scaleFactor;
        scaledHeight = height * scaleFactor;
//This line was added to save the new width and height values.
        scaledSize = CGSizeMake(scaledWidth, scaledHeight); 
		
        // center the image
        if (widthFactor > heightFactor)
        {
            thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5; 
        }
        else 
            if (widthFactor < heightFactor)
            {
                thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
            }
    }       

//This line was added to replace the one below. There we won't crop the picture, but just resize it to the new calculated values.
    UIGraphicsBeginImageContext(scaledSize);
//    UIGraphicsBeginImageContext(targetSize); // this will crop
    
    ...
}

Hope it helps.
Best regards,
Volker
                
> ios camera targetWidth/Height don't match the documentation
> -----------------------------------------------------------
>
>                 Key: CB-183
>                 URL: https://issues.apache.org/jira/browse/CB-183
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 1.0.0
>            Reporter: Durham
>            Assignee: Shazron Abdullah
>             Fix For: 1.6.0
>
>
> According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions] using targetWidth and targetHeight should maintain the aspect ratio of the original photo . The ios implementation does not do this. Instead it makes the shortest side match the desired target, and crops the rest.
> For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024, it results in a 1024x1024 square picture with the excess removed. On android it results in something like 1024x640, and nothing is cropped.
> I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m imageByScalingAndCroppingForSize. This is based off the android implementation.
> {code:title=Camera.m}
> ...
> if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
> {
>     CGFloat newRatio = targetWidth / targetHeight;
>     CGFloat origRatio = width / height;
>     if (origRatio > newRatio) 
>     {
>         targetHeight = (targetWidth * height) / width
>     } 
>     else 
>     {
>         targetWidth = (targetHeight * width) / height;
>     }
> }
> CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
> UIGraphicsBeginImageContext(finalSize);
> CGRect thumbnailRect = CGRectZero;
> thumbnailRect.size.width  = targetWidth;
> thumbnailRect.size.height = targetHeight;
> [sourceImage drawInRect:thumbnailRect];
> ...
> {code}
> I'm currently seeing the problem in 1.0, but from looking at the code it still looks like a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CB-183) ios camera targetWidth/Height don't match the documentation

Posted by "Shazron Abdullah (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CB-183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shazron Abdullah resolved CB-183.
---------------------------------

    Resolution: Fixed

Fix commits:

Commits:
http://git-wip-us.apache.org/repos/asf?p=incubator-cordova-ios.git;a=commit;h=837ab699a88a6742781e90db3dbf3742d516b488

http://git-wip-us.apache.org/repos/asf?p=incubator-cordova-ios.git;a=commit;h=d5f5c39dcd9b66df1846b1240122c9f11526dcf5

http://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=commit;h=4c1f4dc98859eabf86bb510c73dbc1b9eae356e2
                
> ios camera targetWidth/Height don't match the documentation
> -----------------------------------------------------------
>
>                 Key: CB-183
>                 URL: https://issues.apache.org/jira/browse/CB-183
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 1.0.0
>            Reporter: Durham
>            Assignee: Shazron Abdullah
>             Fix For: 1.7.0
>
>
> According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions] using targetWidth and targetHeight should maintain the aspect ratio of the original photo . The ios implementation does not do this. Instead it makes the shortest side match the desired target, and crops the rest.
> For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024, it results in a 1024x1024 square picture with the excess removed. On android it results in something like 1024x640, and nothing is cropped.
> I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m imageByScalingAndCroppingForSize. This is based off the android implementation.
> {code:title=Camera.m}
> ...
> if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
> {
>     CGFloat newRatio = targetWidth / targetHeight;
>     CGFloat origRatio = width / height;
>     if (origRatio > newRatio) 
>     {
>         targetHeight = (targetWidth * height) / width
>     } 
>     else 
>     {
>         targetWidth = (targetHeight * width) / height;
>     }
> }
> CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
> UIGraphicsBeginImageContext(finalSize);
> CGRect thumbnailRect = CGRectZero;
> thumbnailRect.size.width  = targetWidth;
> thumbnailRect.size.height = targetHeight;
> [sourceImage drawInRect:thumbnailRect];
> ...
> {code}
> I'm currently seeing the problem in 1.0, but from looking at the code it still looks like a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CB-183) ios camera targetWidth/Height don't match the documentation

Posted by "Shazron Abdullah (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CB-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13251385#comment-13251385 ] 

Shazron Abdullah commented on CB-183:
-------------------------------------

see https://github.com/apache/incubator-cordova-ios/pull/12
                
> ios camera targetWidth/Height don't match the documentation
> -----------------------------------------------------------
>
>                 Key: CB-183
>                 URL: https://issues.apache.org/jira/browse/CB-183
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 1.0.0
>            Reporter: Durham
>            Assignee: Shazron Abdullah
>             Fix For: 1.7.0
>
>
> According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions] using targetWidth and targetHeight should maintain the aspect ratio of the original photo . The ios implementation does not do this. Instead it makes the shortest side match the desired target, and crops the rest.
> For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024, it results in a 1024x1024 square picture with the excess removed. On android it results in something like 1024x640, and nothing is cropped.
> I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m imageByScalingAndCroppingForSize. This is based off the android implementation.
> {code:title=Camera.m}
> ...
> if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
> {
>     CGFloat newRatio = targetWidth / targetHeight;
>     CGFloat origRatio = width / height;
>     if (origRatio > newRatio) 
>     {
>         targetHeight = (targetWidth * height) / width
>     } 
>     else 
>     {
>         targetWidth = (targetHeight * width) / height;
>     }
> }
> CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
> UIGraphicsBeginImageContext(finalSize);
> CGRect thumbnailRect = CGRectZero;
> thumbnailRect.size.width  = targetWidth;
> thumbnailRect.size.height = targetHeight;
> [sourceImage drawInRect:thumbnailRect];
> ...
> {code}
> I'm currently seeing the problem in 1.0, but from looking at the code it still looks like a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira