@@ -37,24 +37,29 @@ - (void)viewDidLoad {
37
37
NSURL *staticURL = [NSURL URLWithString: @" https://jpegxl.info/logo.jxl" ];
38
38
NSURL *animatedURL = [NSURL URLWithString: @" https://jpegxl.info/anim_jxl_logo.jxl" ];
39
39
40
- [self .imageView1 sd_setImageWithURL: staticURL placeholderImage: nil options: 0 context: nil progress: nil completed: ^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
41
- if (image) {
42
- NSLog (@" %@ " , @" Static JPEG-XL load success" );
43
- }
44
- // TODO, JXL encoding
40
+ // [self.imageView1 sd_setImageWithURL:staticURL placeholderImage:nil options:0 context:nil progress:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
41
+ // if (image) {
42
+ // NSLog(@"%@", @"Static JPEG-XL load success");
43
+ // }
44
+ // // TODO, JXL encoding
45
45
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
46
46
// NSUInteger maxFileSize = 4096;
47
47
// NSData *jxlData = [SDImageJPEGXLCoder.sharedCoder encodedDataWithImage:image format:SDImageFormatJPEGXL options:@{SDImageCoderEncodeMaxFileSize : @(maxFileSize)}];
48
48
// if (jxlData) {
49
49
// NSLog(@"%@", @"JPEG-XL encoding success");
50
50
// }
51
51
// });
52
- }];
53
- [self .imageView2 sd_setImageWithURL: animatedURL placeholderImage: nil completed: ^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
54
- if (image) {
55
- NSLog (@" %@ " , @" Animated JPEG-XL load success" );
56
- }
57
- }];
52
+ // }];
53
+ // [self.imageView2 sd_setImageWithURL:animatedURL placeholderImage:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
54
+ // if (image) {
55
+ // NSLog(@"%@", @"Animated JPEG-XL load success");
56
+ // }
57
+ // }];
58
+
59
+ // Test JXL Encode
60
+ NSData *HDRData = [NSData dataWithContentsOfFile: @" /Users/lizhuoli/Desktop/iso-hdr-demo.jxl" ];
61
+ UIImage *image = [UIImage imageWithData: HDRData];
62
+ [self encodeJXLWithImage: image];
58
63
}
59
64
60
65
- (void )viewWillLayoutSubviews {
@@ -63,6 +68,18 @@ - (void)viewWillLayoutSubviews {
63
68
self.imageView2 .frame = CGRectMake (0 , self.view .bounds .size .height / 2 , self.view .bounds .size .width , self.view .bounds .size .height / 2 );
64
69
}
65
70
71
+ - (void )encodeJXLWithImage : (UIImage *)image {
72
+ NSData *data = [SDImageJPEGXLCoder.sharedCoder encodedDataWithImage: image format: SDImageFormatJPEGXL options: @{
73
+ SDImageCoderEncodeCompressionQuality : @0.68
74
+ }];
75
+ NSCParameterAssert (data);
76
+ [data writeToFile: @" /tmp/a.jxl" atomically: YES ];
77
+
78
+ CIImage *ciimage = [CIImage imageWithData: data];
79
+ NSString *desc = [ciimage description ];
80
+ NSLog (@" Encoded JXL CIImage description: %@ " , desc);
81
+ }
82
+
66
83
- (void )didReceiveMemoryWarning {
67
84
[super didReceiveMemoryWarning ];
68
85
// Dispose of any resources that can be recreated.
0 commit comments