Is there any reference tutorial for getting the image size in small or medium environment.
I just want to know the calculation of image sizes in terms of Width and Height, How can we calculate UIImage size in pixels when It is small, medium or large like in apple mail.
It is just like when we attach image in Mail it asks small, medium, large..
Plz don't provide this as I already gone through this..
Thanks in advance.
Finally seeing from many solutions I got the following solution and done code according this.
We can get images like following.
Small = 320 pixels on longest edge JPEG
Medium = 640 pixels on longest edge JPEG
Large = 1296 pixels on longest edge JPEG
Where typeOfImage = 0,1,2 for small, medium and large respectively.
-(CGSize)getImageWithRespectiveSize:(UIImage *)pImage withType:(NSInteger)typeOfImg
{
CGSize pSize;
if(typeOfImg == 0)
pSize = [self getCGSizesOfImages:320 andImage:pImage];
else if(typeOfImg == 1)
pSize = [self getCGSizesOfImages:640 andImage:pImage];
else if(typeOfImg == 2)
pSize = [self getCGSizesOfImages:1296 andImage:pImage];
else
pSize = CGSizeMake(pImage.size.width, pImage.size.height);
return pSize;
}
-(CGSize)getCGSizesOfImages:(NSInteger)pIntPixels andImage:(UIImage *)pImage
{
CGSize pSize;
if(pImage.size.width > pImage.size.height)
{
CGFloat tmp = pImage.size.height/pImage.size.width*pIntPixels;
pSize = CGSizeMake(pIntPixels, tmp);
}
else if(pImage.size.width < pImage.size.height)
{
CGFloat tmp = pImage.size.width/pImage.size.height*pIntPixels;
pSize = CGSizeMake(tmp, pIntPixels);
}
else
{
CGFloat tmp = pImage.size.height/pImage.size.width*pIntPixels;
pSize = CGSizeMake(tmp, pIntPixels);
}
return pSize;
}
and call to function like this
CGSize size = [self getImageWithRespectiveSize:imgOriginal withType:0];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With