scottcheng / cropit

A "customizable crop and zoom" jQuery plugin.
http://scottcheng.github.io/cropit/
MIT License
875 stars 304 forks source link

doesn't open some images #237

Open yeganehaym opened 7 years ago

yeganehaym commented 7 years ago

i've run the html page and its working for well but then came to know doesn't open some images

yeganehaym commented 7 years ago

thumbnail-bp-x-2

yeganehaym commented 7 years ago

this is an example

rason560 commented 7 years ago

So am I , hope this BUG can be resolved.

monsieur-ricky commented 7 years ago

Same here! Any update on this issue?

monsieur-ricky commented 7 years ago

After a little debugging, i found the cause of this issue. The method onPreImageLoaded validates the selected image based on some parameters like, the container's width and height, the preview size, max zoom, etc. If the image doesn't pass these criteria, it throws an error and the image isn't displayed.

As a temporary fix for my issue, i commented the reject image if clause in the code:

{
    key: 'onPreImageLoaded',
    value: function onPreImageLoaded()
    {
        // if (this.shouldRejectImage({
        //  imageWidth: this.preImage.width,
        //  imageHeight: this.preImage.height,
        //  previewSize: this.previewSize,
        //  maxZoom: this.options.maxZoom,
        //  exportZoom: this.options.exportZoom,
        //  smallImage: this.options.smallImage
        // })) {
        //  this.onImageError(_constants.ERRORS.SMALL_IMAGE);
        //  if (this.image.src) {
        //      this.setImageLoadedClass();
        //  }
        //  return;
        // }

        this.image.src = this.preImage.src;
    }
},

Hope this helps.

ahromyak commented 7 years ago

Got same here. Hope it will be fixed. And yes ricky2k7 fix helped me. But it is only temporary solution. Also if i comment this lines i am not able to zoom- in this image which hasn't opened before. However i understand that it might fail to show because image doesnt fit some requirements. If possible please show how to get call callback function to show what is wrong to show user problem or something. thank you in advance.

tyelford commented 7 years ago

I am also having this issue. It seems to happen with only certain png files for me.

Even happens on the cropit site using the first demo. I have attached two png photos (stock photos from windows). iis.png works fine but the w-brand.png does not load.

I am gathering from the images I have uploaded and ricky2k7's post that the w-brand.png file fails a size constraint?

Would be great to see a fix for this.

iis w-brand

tyelford commented 7 years ago

This can be solved using the smallImage: 'allow' option:

$('.image-editor').cropit({ smallImage: 'allow' });

It still keeps the image size specified by the cropit box but you cannot zoom in on the small image. This makes sense because it will become pixelated.

See issue #102.

kasfulanwar commented 1 year ago

After a little debugging, i found the cause of this issue. The method onPreImageLoaded validates the selected image based on some parameters like, the container's width and height, the preview size, max zoom, etc. If the image doesn't pass these criteria, it throws an error and the image isn't displayed.

As a temporary fix for my issue, i commented the reject image if clause in the code:

{
  key: 'onPreImageLoaded',
  value: function onPreImageLoaded()
  {
      // if (this.shouldRejectImage({
      //  imageWidth: this.preImage.width,
      //  imageHeight: this.preImage.height,
      //  previewSize: this.previewSize,
      //  maxZoom: this.options.maxZoom,
      //  exportZoom: this.options.exportZoom,
      //  smallImage: this.options.smallImage
      // })) {
      //  this.onImageError(_constants.ERRORS.SMALL_IMAGE);
      //  if (this.image.src) {
      //      this.setImageLoadedClass();
      //  }
      //  return;
      // }

      this.image.src = this.preImage.src;
  }
},

Hope this helps.

It works!