<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Resize a UIImage the right way</title>
	<atom:link href="http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/feed/" rel="self" type="application/rss+xml" />
	<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/</link>
	<description>Random thoughts, humor, and helpful tips</description>
	<lastBuildDate>Thu, 02 Feb 2012 00:31:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Bill Frowine</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-88416</link>
		<dc:creator>Bill Frowine</dc:creator>
		<pubDate>Thu, 02 Feb 2012 00:31:36 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-88416</guid>
		<description>Hi I was just using the UIImage+Resize category and am getting the following errors:

1. Semantic Issue enumeration values uiimage orientation not handled in switch.  here is the method it is referring to:

switch (self.imageOrientation) {
        case UIImageOrientationDown:           // EXIF = 3
        case UIImageOrientationDownMirrored:   // EXIF = 4
            transform = CGAffineTransformTranslate(transform, newSize.width, newSize.height);
            transform = CGAffineTransformRotate(transform, M_PI);
            break;

2. symantec issue 4 enumeration values not handled in switch uiimage orientation up, uiimage orientaton down, uiimage orientation  left, uiimage orientation right.  Here is the method:


switch (self.imageOrientation) {
        case UIImageOrientationUpMirrored:     // EXIF = 2
        case UIImageOrientationDownMirrored:   // EXIF = 4
            transform = CGAffineTransformTranslate(transform, newSize.width, 0);
            transform = CGAffineTransformScale(transform, -1, 1);
            break;</description>
		<content:encoded><![CDATA[<p>Hi I was just using the UIImage+Resize category and am getting the following errors:</p>
<p>1. Semantic Issue enumeration values uiimage orientation not handled in switch.  here is the method it is referring to:</p>
<p>switch (self.imageOrientation) {<br />
        case UIImageOrientationDown:           // EXIF = 3<br />
        case UIImageOrientationDownMirrored:   // EXIF = 4<br />
            transform = CGAffineTransformTranslate(transform, newSize.width, newSize.height);<br />
            transform = CGAffineTransformRotate(transform, M_PI);<br />
            break;</p>
<p>2. symantec issue 4 enumeration values not handled in switch uiimage orientation up, uiimage orientaton down, uiimage orientation  left, uiimage orientation right.  Here is the method:</p>
<p>switch (self.imageOrientation) {<br />
        case UIImageOrientationUpMirrored:     // EXIF = 2<br />
        case UIImageOrientationDownMirrored:   // EXIF = 4<br />
            transform = CGAffineTransformTranslate(transform, newSize.width, 0);<br />
            transform = CGAffineTransformScale(transform, -1, 1);<br />
            break;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tal</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-88208</link>
		<dc:creator>Tal</dc:creator>
		<pubDate>Tue, 31 Jan 2012 13:16:59 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-88208</guid>
		<description>Hi.

I want to take images taken with the iphone camera (landscape or portrait) and resize them to a manageable size (around 120kb) while preserving most of the quality.

What should I send as the newSize for the resizedImage? 640x480 or 480x640 ?

I didn&#039;t understand the &quot;result will always be &quot;up&quot;.
it means the resized image will always result in 480x640 ?

Thanks alot!</description>
		<content:encoded><![CDATA[<p>Hi.</p>
<p>I want to take images taken with the iphone camera (landscape or portrait) and resize them to a manageable size (around 120kb) while preserving most of the quality.</p>
<p>What should I send as the newSize for the resizedImage? 640&#215;480 or 480&#215;640 ?</p>
<p>I didn&#8217;t understand the &#8220;result will always be &#8220;up&#8221;.<br />
it means the resized image will always result in 480&#215;640 ?</p>
<p>Thanks alot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trevor</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-87212</link>
		<dc:creator>Trevor</dc:creator>
		<pubDate>Sun, 22 Jan 2012 16:01:03 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-87212</guid>
		<description>The thumbnail code does preserve aspect ratio; it uses UIViewContentModeScaleAspectFill. It produces a square image because thumbnails are usually squared off. (See iPhoto&#039;s &quot;Events&quot; view for an example.) But it would be nice to offer more flexibility.</description>
		<content:encoded><![CDATA[<p>The thumbnail code does preserve aspect ratio; it uses UIViewContentModeScaleAspectFill. It produces a square image because thumbnails are usually squared off. (See iPhoto&#8217;s &#8220;Events&#8221; view for an example.) But it would be nice to offer more flexibility.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nik</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-87204</link>
		<dc:creator>nik</dc:creator>
		<pubDate>Sun, 22 Jan 2012 14:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-87204</guid>
		<description>Anyone care to create new versions of these categories that include the above fixes? Not for me, I am going to do it now but for others who might need it...

This is also missing the one thing I need which is scale an image to a (single) max width/height, preserving the aspect ratio. Why should thumbnails be square, that makes no sense to me. If I am displaying square thumbnails, it&#039;s much better to handle this on the UIImageView level. Let the view decide whether to display the image as aspect fit, fill, etc rather than putting this in the scaled image.</description>
		<content:encoded><![CDATA[<p>Anyone care to create new versions of these categories that include the above fixes? Not for me, I am going to do it now but for others who might need it&#8230;</p>
<p>This is also missing the one thing I need which is scale an image to a (single) max width/height, preserving the aspect ratio. Why should thumbnails be square, that makes no sense to me. If I am displaying square thumbnails, it&#8217;s much better to handle this on the UIImageView level. Let the view decide whether to display the image as aspect fit, fill, etc rather than putting this in the scaled image.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: moKorean</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-77703</link>
		<dc:creator>moKorean</dc:creator>
		<pubDate>Tue, 29 Nov 2011 09:19:09 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-77703</guid>
		<description>Thanks!! it Works!. and &#039;PNG&#039; files works good toooo,</description>
		<content:encoded><![CDATA[<p>Thanks!! it Works!. and &#8216;PNG&#8217; files works good toooo,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: horseshoe7</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-76692</link>
		<dc:creator>horseshoe7</dc:creator>
		<pubDate>Wed, 23 Nov 2011 18:28:02 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-76692</guid>
		<description>I &quot;fixed&quot; the problem in that the error comes from being unable to create the context due to invalid input parameters (which are being read from the original image, which may have been encoded wrong).

When you think about it, who cares so much about the input file because we are defining here what the output image will be.  So, in UIImage+Resize.m around line 120, replace the line CGContextRef bitmap = ...  with

    CGContextRef bitmap = CGBitmapContextCreate(
NULL,
newRect.size.width, 
newRect.size.height, 
8, /* bits per channel */
(newRect.size.width * 4),    /* 4 channels per pixel * numPixels/row */
CGColorSpaceCreateDeviceRGB(), 
kCGImageAlphaPremultipliedLast
);

and that seemed to make the errors go away.  Images look ok too.</description>
		<content:encoded><![CDATA[<p>I &#8220;fixed&#8221; the problem in that the error comes from being unable to create the context due to invalid input parameters (which are being read from the original image, which may have been encoded wrong).</p>
<p>When you think about it, who cares so much about the input file because we are defining here what the output image will be.  So, in UIImage+Resize.m around line 120, replace the line CGContextRef bitmap = &#8230;  with</p>
<p>    CGContextRef bitmap = CGBitmapContextCreate(<br />
NULL,<br />
newRect.size.width,<br />
newRect.size.height,<br />
8, /* bits per channel */<br />
(newRect.size.width * 4),    /* 4 channels per pixel * numPixels/row */<br />
CGColorSpaceCreateDeviceRGB(),<br />
kCGImageAlphaPremultipliedLast<br />
);</p>
<p>and that seemed to make the errors go away.  Images look ok too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-76548</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Wed, 23 Nov 2011 00:39:01 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-76548</guid>
		<description>I was having the same issues on iOS5. This fixed it.

Change the resizeImage method in UIImage+Resize.m to directly specify rather than derive the colour space and alpha information.

    // make the following changes.

    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    
    CGContextRef bitmap = CGBitmapContextCreate(NULL, newRect.size.width, newRect.size.height, 8, 4 * newRect.size.width, colorSpace, kCGImageAlphaPremultipliedFirst);
    
    CGColorSpaceRelease(colorSpace);

    // rest of code continues.

Cheers,
Matt</description>
		<content:encoded><![CDATA[<p>I was having the same issues on iOS5. This fixed it.</p>
<p>Change the resizeImage method in UIImage+Resize.m to directly specify rather than derive the colour space and alpha information.</p>
<p>    // make the following changes.</p>
<p>    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();</p>
<p>    CGContextRef bitmap = CGBitmapContextCreate(NULL, newRect.size.width, newRect.size.height, 8, 4 * newRect.size.width, colorSpace, kCGImageAlphaPremultipliedFirst);</p>
<p>    CGColorSpaceRelease(colorSpace);</p>
<p>    // rest of code continues.</p>
<p>Cheers,<br />
Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: horseshoe7</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-76359</link>
		<dc:creator>horseshoe7</dc:creator>
		<pubDate>Mon, 21 Nov 2011 23:50:45 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-76359</guid>
		<description>I&#039;m getting this error as well.  Does anyone know what it could be?  Please help!</description>
		<content:encoded><![CDATA[<p>I&#8217;m getting this error as well.  Does anyone know what it could be?  Please help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Salem Sayed</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-75033</link>
		<dc:creator>Salem Sayed</dc:creator>
		<pubDate>Sun, 13 Nov 2011 14:51:05 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-75033</guid>
		<description>To fix those errors, i re-sized the imaged before adding the rounded rect to 48x48, that magically solved everything.</description>
		<content:encoded><![CDATA[<p>To fix those errors, i re-sized the imaged before adding the rounded rect to 48&#215;48, that magically solved everything.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: UIImage in iOS 5, Orientation and Resize &#124; Another blog bites the dust</title>
		<link>http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/comment-page-3/#comment-74251</link>
		<dc:creator>UIImage in iOS 5, Orientation and Resize &#124; Another blog bites the dust</dc:creator>
		<pubDate>Mon, 07 Nov 2011 07:15:57 +0000</pubDate>
		<guid isPermaLink="false">http://vocaro.com/trevor/blog/?p=516#comment-74251</guid>
		<description>[...] flip and/or rotate the image according to its orientation value.Being my lazy self I used the fine code of Trevor Harmon in UIImage+Resize. Trevor added some categories to make handling UIImage a bit [...]</description>
		<content:encoded><![CDATA[<p>[...] flip and/or rotate the image according to its orientation value.Being my lazy self I used the fine code of Trevor Harmon in UIImage+Resize. Trevor added some categories to make handling UIImage a bit [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

