Skip to content

Commit

Permalink
fix ios image compress issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangwei committed May 25, 2018
1 parent e3288ef commit db0b836
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ios/UIImage+Luban_iOS_Extension_h.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ + (NSData *)lubanCompressImage:(UIImage *)image withMask:(NSString *)maskName {
int thumbW = fixelW % 2 == 1 ? fixelW + 1 : fixelW;
int thumbH = fixelH % 2 == 1 ? fixelH + 1 : fixelH;

double scale = ((double)fixelW/fixelH);
double scale = ((double)fixelW/(double)fixelH);

if (scale <= 1 && scale > 0.5625) {

Expand Down Expand Up @@ -129,7 +129,7 @@ + (NSData *)compressWithImage:(UIImage *)image thumbW:(int)width thumbH:(int)hei
UIImage *thumbImage = [image fixOrientation];
thumbImage = [thumbImage resizeImage:image thumbWidth:width thumbHeight:height withMask:maskName];

int qualityCompress = 1.0;
float qualityCompress = 1.0f;

NSData *imageData = UIImageJPEGRepresentation(thumbImage, qualityCompress);

Expand Down Expand Up @@ -161,8 +161,10 @@ - (UIImage *)resizeImage:(UIImage *)image thumbWidth:(int)width thumbHeight:(int
inSampleSize *= 2;
}
}
int heightRatio = (int)ceil(outH / (float) height);
int widthRatio = (int)ceil(outW / (float) width);
int outWith = (int)((outW / (float) width)*10);
int outHeiht = (int)((outH / (float) height)*10);
float heightRatio = outHeiht/10.0;
float widthRatio = outWith/10.0;

if (heightRatio > 1 || widthRatio > 1) {

Expand Down

0 comments on commit db0b836

Please sign in to comment.