Skip to content

Fix: Create JPEG images without embedded ICC profile #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion image_editor_common/ios/Classes/EditorUIImageHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#import "EditorUIImageHandler.h"
#import <CoreImage/CIFilterBuiltins.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>


void releaseCGContext(CGContextRef ref) {
Expand Down Expand Up @@ -114,7 +116,16 @@ - (NSData *)outputMemory {
if (fmt.format == 0) {
return UIImagePNGRepresentation(outImage);
} else {
return UIImageJPEGRepresentation(outImage, ((CGFloat) fmt.quality) / 100);
NSMutableData *data = [NSMutableData new];
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)data, kUTTypeJPEG, 1, NULL);
NSDictionary *options = @{
(id)kCGImageDestinationLossyCompressionQuality : @(((CGFloat)fmt.quality) / 100),
(id)kCGImageDestinationOptimizeColorForSharing: (id)kCFBooleanTrue
};
CGImageDestinationAddImage(imageDestination, outImage.CGImage, (CFDictionaryRef)options);
CGImageDestinationFinalize(imageDestination);
CFRelease(imageDestination);
return data;
}
}

Expand Down
13 changes: 12 additions & 1 deletion image_editor_common/ios/Classes/FIMerger.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#import "FIMerger.h"
#import "EditorUIImageHandler.h"
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>

@implementation FIMerger

Expand Down Expand Up @@ -35,7 +37,16 @@ - (NSData *)outputMemory:(UIImage *)image {
if (fmt.format == 0) {
return UIImagePNGRepresentation(image);
} else {
return UIImageJPEGRepresentation(image, ((CGFloat)fmt.quality) / 100);
NSMutableData *data = [NSMutableData new];
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)data, kUTTypeJPEG, 1, NULL);
NSDictionary *options = @{
(id)kCGImageDestinationLossyCompressionQuality : @(((CGFloat)fmt.quality) / 100),
(id)kCGImageDestinationOptimizeColorForSharing: (id)kCFBooleanTrue
};
CGImageDestinationAddImage(imageDestination, image.CGImage, (CFDictionaryRef)options);
CGImageDestinationFinalize(imageDestination);
CFRelease(imageDestination);
return data;
}
}

Expand Down