Different crop results
tpai opened this issue · 30 comments
I'm not seeing this problem. It might be something specific with the images that you're using. Would you mind providing them?
Thanks, I definitely see the problem now. Not sure what's causing it though. I'll dig into it when I have more time.
In the meantime, you maybe able to destroy the croppie instance and reinitialize it.
Even I am facing the same issue with the latest version of Croppie, older version was working just fine.
Same issue and seems related to the images it self.
If i save the exact same image with a bit less quality the issue arises.
Issue also occurs when getting base64 result of viewport. Enabling enableOrientation options seems to have helped in my situation.
Same issue here.
I have this issue too, even more so when i reload a second time the same image. Any ideas?
I find that the more times I use the croppie, the more likely it is to give wrong results. So, it is really helpful to destroy the croppie and reinitialize it after getting the cropping result every time.
Can you provide an example of this please? i'm suffering a lot with this. I'm using the vue.js version but same problems. I am setting it up as a tag in my code so not sure after that how to destroy it and recreate it. Your help is much appreciated.
Dear enzeberg, thank you, sadly i can't emplement this, i'm using the vue version of croppie and these dont work. I'm stuck for now, not sure what to do.
@nicolasvahidzein
Did you set the correct links to the files needed for the html file?
(You need to change the paths to the linked files in your own machine.)
First choosing file
Choose file
Click "设为头像” button to get the result
(After clicking the "设为头像" button, the croppie will be destroyed and reinitialized, and the "设为头像“ button will disappear.)
Second choosing file
Choose file
Click "设为头像” button to get the result
Yes my friend, i did. The css is and loading is fine. The problem is that i am using the vue-croppie version and it's a container for croppie but i'm not lucky, also i am passing the data from my webcam and then sometimes i get a bad result.
I'm sorry, friend. I have no idea about vue-croppie. In fact, I know very little about web development. (#...#)
Not a problem, thank you very much for all your help.
I'm not good in English. but this would be help vue.js users.
- don't use vue-croppie, use croppie instead.
install:
npm install croppie
import:
import Croppie from 'croppie'
import 'croppie/croppie.css'
- in component file:
data () {
return {
croppieElm: null,
cropped: null
}
- in template:
<span id="croppieContainer"></span>
<img v-bind:src="cropped">
<button @click="rotate(-90)">Rotate Left</button>
<button @click="rotate(90)">Rotate Right</button>
<button @click="crop()">Crop</button>
<input id="fileItem" type="file" @change="bindCroppie($event)">
- in mounted():
mounted () {
var div = document.createElement("div")
document.getElementById('croppieContainer').append(div)
this.croppieElm = new Croppie(div, {
boundary: { width: 300, height: 300 },
viewport: { width: 250, height: 200 },
enableOrientation: true,
});
this.croppieElm.bind({
url: 'http://i.imgur.com/Fq2DMeH.jpg',
})
}
-
in method:
bindCroppie (event) { // destroy croppie document.getElementById('croppieContainer').innerHTML = '' this.croppieElm.destroy() // create new element for croppie var div = document.createElement("div") document.getElementById('croppieContainer').append(div) this.croppieElm = new Croppie(div, { boundary: { width: 300, height: 300 }, viewport: { width: 250, height: 200 }, enableOrientation: true, }) this.croppieElm.bind({ url: window.URL.createObjectURL(event.target.files[0]), zoom: 0.1 }) }, crop() { let options = { type: 'base64', size: 'viewport', format: 'jpeg', circle: false } let vm = this this.croppieElm.result(options).then(function (output) { vm.cropped = output }); }, rotate(rotationAngle) { this.croppieElm.rotate(rotationAngle); }
You are mighty kind Arma, that was amazing!!!!!!!!!!!! Thank you so much. How do i give you a star or a million thumbs up? This worked perfectly. Thanks.
Wouldn't it be wiser to improve the Vue component rather than saying to not use the Vue component?
/cc @jofftiquez
@brunogaspar thanks for informing me.
Hey Joff and Bruno,
Yes indeed it would be better but Joff here is very busy and we don't have the luxury to wait while we are designing an app as you must already know. I submitted many issues we are still waiting to hear back from.
If Joff has the time i'm still here to work with him on those but until then @arma2521 provide the perfect solution and the module now works like a charm.
The ball is in my friend's Joff court. On that note, Joff, any progress on what we discussed on gitter?
@nicolasvahidzein Yup, i totally understand :)
I'm using a similar solution, but i'm still using the Vue component.
Basically, when the file get's selected i destroy and i re-initialize the croppie instance again (the same way it's being done without the Vue component)
onFileChange(event, instance) {
var files = event.target.files || event.dataTransfer.files
if (! files.length) {
return
}
var croppieInstance = this.$refs[instance]
croppieInstance.destroy()
croppieInstance.initCroppie()
croppieInstance.bind({
url: window.URL.createObjectURL(files[0])
})
},
The file input i'm using
<input id="file" type="file" @change="onFileChange($event, 'this-is-the-croppie-ref-name')" accept="image/*" />
So far, it's working as expected
@nicolasvahidzein and @brunogaspar may we discuss in this in our gitter so we don't disturb this thread hehe. Thanks! I'm looking into it now.
I'm getting this issue too, using version 2.5.0
having to destroy and re-init, instead of just passing a new image to "bind"
Yes, I would guess it is the same issue on both threads. And it turns out I am getting the issue too, version 2.5.0.
Left is Croppie's output, Right is the original image. Taken from the demo site. Note how the resulting image is warmer than the original?
Also, when exporting a png with a circle crop, the alpha channel part of the image is a light, transparent grey, and not purely transparent pixels. See Below.
Lastly, on the circular crop, the aliasing of the circle can cause white pixels to show up on the edges of the circle.
This behavior was seen on: Chrome Mac Version 61.0.3163.100 (Official Build) (64-bit)
This is now an issue. See #434
I got like this problem in SweetAlert2 modal, If I put <img>
DOM in swal()
somehow and sometimes the result like this issues. But if I put <img>
DOM into another element they're working as expect.
This is the problem of element or CSS cause this issues? I tried max-width: none !important;
its doesn't works.
Sorry for my English by the way.
@MatthewAry Your issue is different from this issue. I'd recommend adding it to a new issue.
@nakorndev Same goes for you.
@thedustinsmith Okay, I've made it a separate issue.