Kingfisher icon indicating copy to clipboard operation
Kingfisher copied to clipboard

ResizeImage is Jerking

Open nickp4488 opened this issue 1 year ago • 3 comments

https://github.com/user-attachments/assets/cf68f7d1-0888-459d-a20c-dedefe228aee

Hello, I am using resize image processor to resize image as per screen width and pre-defined maxHeight. It is working fine. but image is shown before resize and then jerks after resize.

My code:

img.kf.indicatorType = .activity
img.kf.setImage(with: url, placeholder: nil,
                    options: [
                        .transition(.fade(0.5)),
                        .processor(ResizingImageProcessor(referenceSize: CGSize(width: img.frame.width, height: 300),
                                                          mode: .aspectFit))])

Can you please correct me if I am doing anything wrong.

nickp4488 avatar Aug 23 '24 18:08 nickp4488

Hi, @nickp4488

Based on the code you provided, it shouldn’t cause the issue you’re describing. However, I recommend checking if the setImage method is being called multiple times, possibly with different values for img.frame.width.

If that’s the case, please ensure that the setImage is called at the correct timing. If the image size depends on the current view hierarchy, make sure to set the image after the layout has completed to obtain the correct width.

onevcat avatar Aug 24 '24 09:08 onevcat

Hello @onevcat I am reloading cell manually after a second, If I stop reloading cell then image is shown as ssail origional without resizing. After reload cell, resize image will show.

nickp4488 avatar Aug 24 '24 09:08 nickp4488

Hi, @nickp4488

Based on the code you provided, it shouldn’t cause the issue you’re describing. However, I recommend checking if the setImage method is being called multiple times, possibly with different values for img.frame.width.

If that’s the case, please ensure that the setImage is called at the correct timing. If the image size depends on the current view hierarchy, make sure to set the image after the layout has completed to obtain the correct width.

can you please check this issue if possible? thank you,

nickp4488 avatar Aug 29 '24 16:08 nickp4488