GPUImage doubles image size - iOS/Swift -
i trying convert image grayscale 1 using gpuimage. wrote extension work done. grayscale thing okay. output image has become doubled in size. in case need image in exact size. can please me on this? highly appreciated.
this extension wrote
import uikit import gpuimage extension uiimage { public func grayscale() -> uiimage?{ var processedimage = self print("1: "+"\(processedimage.size)") let image = gpuimagepicture(image: processedimage) let grayfilter = gpuimagegrayscalefilter() image?.addtarget(grayfilter) grayfilter.usenextframeforimagecapture() image?.processimage() processedimage = grayfilter.imagefromcurrentframebuffer() print("2: "+"\(processedimage.size)") return processedimage } }
this output in console
edit: know image can resized later on. need know why happening , there keep image size using gpuimage.
try scale image later:
if let cgimage = processedimage.cgimage { //the scale value 2.0 here should replaced original image's scale. let scaledimage = uiimage(cgimage: cgimage, scale: 2.0, orientation: processedimage.imageorientation) return scaledimage }
Comments
Post a Comment