Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image combining doesn't work properly, fixes described #13

Open
sickoftalking opened this issue May 8, 2018 · 1 comment
Open

Image combining doesn't work properly, fixes described #13

sickoftalking opened this issue May 8, 2018 · 1 comment

Comments

@sickoftalking
Copy link

I downloaded this code because I wanted to be able to extract frames from GIFs, but I found a few problems applying it to some GIFs that used the "Leave" method for image disposal, where it would combine a frame with the previous frame using transparency.

There were two problems --

The first is that it copied the image to the composite sprite using the maximum height and width, like so,
imagecopyresampled($sprite, $img, $this->frameSources[$i]["offset_left"], $this->frameSources[$i]["offset_top"], 0, 0, $this->gifMaxWidth, $this->gifMaxHeight, $this->gifMaxWidth, $this->gifMaxHeight);

However, if the second image was smaller in dimensions than the first, this would effectively black out anything past the dimensions of the first. The compositing would need to be done like this instead,
imagecopyresampled($sprite, $img, $this->frameSources[$i]["offset_left"], $this->frameSources[$i]["offset_top"], 0, 0, $this->frameSources[$i]["width"], $this->frameSources[$i]["height"], $this->frameSources[$i]["width"], $this->frameSources[$i]["height"]);

Of course, that would only be for frames with the "Leave" method; otherwise it makes sense to black it out if the dimensions are kept to the maximum height and width. Though I'm not sure that's how animated GIFs work.

Second, it used the current index to determine the disposal method,
$this->frameSources[$i]['disposal_method']

While the disposal method applies to the previous frame, so needs to be taken from the previous image data. So it needs to be addressed like this,
$this->frameSources[$i-1]['disposal_method']

The project obviously looks like it has a lot left unimplemented and it looks like @Sybio has been gone for a while, but I'm leaving this documented here for anyone that might find interest in it.

@DiegoFleitas
Copy link

Same issue, on my part I'm gonna use PHP-FFMpeg since this project is not maintained anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants