-
Notifications
You must be signed in to change notification settings - Fork 165
SpectrumKit not working with screenshot images in iOS 13 #223
Description
I have following version of spectrum
SpectrumCore (1.1.0)
SpectrumKit (1.1.0)
mozjpeg (3.3.2)
spectrum-folly (2019.01.21.00)
When I try to compress a screenshot I'm getting a plain white image. I'm not getting any error. I'm testing on iPhone XR iOS 13.1.2.
Attaching some input images and some screenshot of what I'm getting as output.
I'm not getting any kind of error when compressing these images just plain white image I'm getting
This is my image picking code
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:@"public.image"]){
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
UIImage *transcoded = [self transcodeImage:image];
}
}
- (UIImage*)transcodeImage:(UIImage*)image {
FSPSpectrum *spectrum = [[FSPSpectrum alloc] initWithPlugins:@[[FSPJpegPlugin new]]
configuration:nil];
FSPEncodeRequirement *encodeRequirement =
[FSPEncodeRequirement encodeRequirementWithFormat:FSPEncodedImageFormat.jpeg
mode:FSPEncodeRequirementModeLossy
quality:70];
FSPConfiguration * configuration = [[FSPConfiguration alloc]init];
FSPTransformations *transformations = [FSPTransformations new];
transformations.resizeRequirement =
[[FSPResizeRequirement alloc] initWithMode:FSPResizeRequirementModeExactOrSmaller
targetSize:CGSizeMake(1024, 1024)];
FSPEncodeOptions *options =
[FSPEncodeOptions encodeOptionsWithEncodeRequirement:encodeRequirement
transformations:transformations
metadata:nil
configuration:configuration
outputPixelSpecificationRequirement:nil];
NSError *error;
FSPResultData *result = [spectrum encodeImage:image options:options error:&error];
if (result.result.didSucceed && result.data) {
UIImage* image = [UIImage imageWithData:result.data];
if (image) {
return image;
}
}
return image;
}
Does anyone knows any fix. I have to release the app on store and it's the only issue I'm stuck with.
I've tried same images on facebook and these are working perfectly.
Edit : Updating targetSize:CGSizeMake(2048, 2048) in FSPResizeRequirement produces the below image
Edit 2 : Updating targetSize:CGRectZero in FSPResizeRequirement always gives error and I'm not able to compress the image
Here is the error log
Printing description of error:
Error Domain=com.facebook.spectrum Code=255 "(null)" UserInfo={com.facebook.spectrum.error-name=scalingX > 0, com.facebook.spectrum.error-location=facebook::spectrum::core::proc::ScalingBlockImpl::ScalingBlockImpl(const image::pixel::Specification &, const image::Size &, const image::Size &):62}
Edit 3 : Same code works fine in iPhone 6 (iOS 12.4.6)



