0

Is it possible to resize image using CIFilter? I know CILanczosScaleTransform, but it resizes image maintaining proportions. And I need to resize image without maintaining proportions. How to do that?

hockeyman
  • 1,141
  • 6
  • 27
  • 57

3 Answers3

4

Why do you think CILanczosScaleTransform maintains proportions? CILanczosScaleTransform has a parameter @"inputAspectRatio" or kCIInputAspectRatioKey which allows you to scale and change the proportions. You can do it with

[filter setValue:[NSNumber numberWithFloat:0.7] forKey:@"inputAspectRatio"];

I took this from documents and didn't try it myself but am sure (due to my experiments with CIFilter) it works.

Heinrich Giesen
  • 1,765
  • 1
  • 11
  • 8
  • Note that `CILanczosScaleTransform` sets the output _height_ according to the `kCIInputScaleKey`. The output width is the input width multiplied by `kCIInputScaleKey*kCIInputAspectRatioKey`. – Nestor Sep 15 '18 at 18:38
2

Use CIAffineTransform instead of CILanczosScaleTransform. Set a and d to your desired scale values. This will shrink or stretch your image to any proposition.

0

All CIFilter is below. I suppose there is no filter to resize image.

  • CIAdditionCompositing
  • CIAffineTransform
  • CICheckerboardGenerator
  • CIColorBlendMode
  • CIColorBurnBlendMode
  • CIColorControls
  • CIColorCube
  • CIColorDodgeBlendMode
  • CIColorInvert
  • CIColorMatrix
  • CIColorMonochrome
  • CIConstantColorGenerator
  • CICrop
  • CIDarkenBlendMode
  • CIDifferenceBlendMode
  • CIExclusionBlendMode
  • CIExposureAdjust
  • CIFalseColor
  • CIGammaAdjust
  • CIGaussianGradient
  • CIHardLightBlendMode
  • CIHighlightShadowAdjust
  • CIHueAdjust
  • CIHueBlendMode
  • CILightenBlendMode
  • CILinearGradient
  • CILuminosityBlendMode
  • CIMaximumCompositing
  • CIMinimumCompositing
  • CIMultiplyBlendMode
  • CIMultiplyCompositing
  • CIOverlayBlendMode
  • CIRadialGradient
  • CISaturationBlendMode
  • CIScreenBlendMode
  • CISepiaTone
  • CISoftLightBlendMode
  • CISourceAtopCompositing
  • CISourceInCompositing
  • CISourceOutCompositing
  • CISourceOverCompositing
  • CIStraightenFilter
  • CIStripesGenerator
  • CITemperatureAndTint
  • CIToneCurve
  • CIVibrance
  • CIVignette
  • CIWhitePointAdjust
Feel Physics
  • 2,783
  • 4
  • 25
  • 38
  • Can you explain how you created this list? I tried NSLog(@"filterNamesInCategories %@", [CIFilter filterNamesInCategories:nil] ); and got much more filters. One of them was CILanczosScaleTransform which scales images. – Heinrich Giesen Aug 13 '12 at 15:43
  • This looks incomplete, or at least out of date. In iOS 6 there are 93 filters. – Ron Aug 13 '13 at 15:39
  • CILanczosScaleTransform available on OS X only. Not in iOS. He might have listed out from iOS. – rakeshNS Dec 07 '14 at 17:43