tui.image-editor icon indicating copy to clipboard operation
tui.image-editor copied to clipboard

Image Editor is not resizing just after image is loaded.

Open Silver-IT opened this issue 3 years ago • 2 comments

Describe the bug The size of imageEditor is not updated when we load new image. It is same on both cases;

  1. when we load image using includeUI option.
  2. when we load image using Load button

Expected behavior As soon as the new image is loaded, it will call the resizeEditor function sending imageSize attribute and the expected behavior is to update size of ImageEditor according to the new image size passed by imageSize attribute.

Gazing the code

resizeEditor({ uiSize, imageSize = this.imageSize } = {}) {
    if (imageSize !== this.imageSize) {
      this.imageSize = imageSize;
    }
    if (uiSize) {
      this._setUiSize(uiSize);
    }
    ...
}

this.imageSize variable is updated to passed imageSize attribute but it isn't used in any places. Which means that the size of the newly-loaded image is not doing anything to update the size of imageEditor.

Additional context This is one of priority and critical bug and needs to be fixed soon in my point of view.

Silver-IT avatar May 28 '21 16:05 Silver-IT

@Silver-IT Thank you for your report. I will resolve it after checking.

lja1018 avatar Jun 02 '21 02:06 lja1018

Not sure if my issue is related to this or not. I also get the image dimensions in the resize control not updating after the first load (load a different image after the first and the control doesn't update).

However, more importantly, it also appears that most of the time images can't be resized at all. Adjusting the slider causes the value to go to NaN and the resize is then broken. This may all be related to the way sizes are loading in and used. However, it appears that when I use my old resize hack (in the original resize feature request ticket), then the image load that I do appears to cause the resize controls to be fixed (and they continue to work for subsequently loaded images). Something about the initial image loading via the "Load" button that seems to be the likely culprit.

Notably, this second NaN bit happens when embedded the editor in my own project, however it does not happen when using the hosted example here: https://nhn.github.io/tui.image-editor/latest/tutorial-example01-includeUi

Happy to test any fixes / provide test images that I know break. Can create a new ticket if they turn out to not be related.

arimus avatar Nov 16 '21 02:11 arimus