Page 1 of 2

Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T14:52:40-07:00
by BajungaDustin
i have a series of images that i need to work on getting into GIF formate and be under 10 seconds and 10 MB

There are roughly 700 images in the sequence.
The current Gif is working but its 50 MB


I want to start by dropping the quality down to 720 instead of 1080
Then From there i want to Crop out the wasted space
Image

But there are a lot of images so how can i do this in a batch.

I would be willing to do multiple runs trimming one side at a time if i need to.

You guys are way better at this than i am. Any help would be great

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T15:37:35-07:00
by fmw42
Is the wasted space where you have drawn zig-zag lines? What about the horizontal and vertical lines? Did you draw them or were they in the image?

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images,

See viewtopic.php?f=1&t=9620

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T16:43:51-07:00
by BajungaDustin
fmw42 wrote:Is the wasted space where you have drawn zig-zag lines? What about the horizontal and vertical lines? Did you draw them or were they in the image?

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images,

See viewtopic.php?f=1&t=9620
Ah yeah sorry.

Windows 10
Image


And yeah.. everything inside the red box is the area i want to keep. I drew all the red lines.
and i dont really have a command for this yet. Thats more or less what im looking at how to make is the command
to batrch crop these

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T16:47:57-07:00
by snibgo
Does "-trim" do what you want? Possibly with "-fuzz XX%" before the trim?

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T16:59:37-07:00
by BajungaDustin
snibgo wrote:Does "-trim" do what you want? Possibly with "-fuzz XX%" before the trim?
Im not sure... i think that trim is possibly what im looking for but im not sure how to use it.
And im not sure about fuzz.. i used that to get rid of the green. (this image is really just a reference because its the exact same positioning ive already got rid of the green... There is just now a lot of wasted space on the left side of the image..

like.. its a 1080p gif that doesnt need to be with about 70% of each image that basically just needs to go

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T17:01:20-07:00
by BajungaDustin
Basically i want to go from This

Image

to this

Image

and before i do that i need to resize all the images to 1280x720 instead of 1920x1080

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T17:05:16-07:00
by fmw42
try this

Code: Select all

convert image -fuzz XX% -trim +repage result
You will have to play with XX. Start low and increase it.

Just make XX as small as possible that gets rid of the background color, so that you do not lose part of your figure. But XX may need to be significant (30% or so) since you likely will have some antialiasing (mixing of the background color with the edges of your figure) so that you need a large XX since the background color will not be a constant. If the background color is a constant then XX can be 0 or a few percent if you have saved the image as JPG, which may change colors due to the lossy compression in blocks.

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T17:08:05-07:00
by BajungaDustin
fmw42 wrote:try this

Code: Select all

convert image -fuzz XX% -trim +repage result
You will have to play with XX. Start low and increase it.

Just make XX as small as possible that gets rid of the background color, so that you do not lose part of your figure. But XX may need to be significant (30% or so) since you likely will have some antialiasing (mixing of the background color with the edges of your figure) so that you need a large XX since the background color will not be a constant. If the background color is a constant then XX can be 0 or a few percent if you have saved the image as JPG, which may change colors due to the lossy compression in blocks.

I guess i may have misslead you.. my background is already transparent. The file size is just too big in its current state.
Im not trying to get rid of the background color. I just need to make the images smaller because nothing happens on the left side of the page.. i need to "trim off some of the transparent wasted space"..

The character goes from standing.. to kneeling.. to standing again.. nothing else.
So all the space around him is just making the GIF bigger than it needs to be

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T17:18:52-07:00
by BajungaDustin
This is what i have so far.. and as you can see there is a lot of room to crop this out and make it smaller.

Image

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T17:34:26-07:00
by BajungaDustin
ok i got the resize done

Code: Select all

>Mogrify -resize 1280x720 00*.png
that worked like a charm.

I also tried Mogrify -Trim on a test image and it trimmed perfectly like i wanted.. but it was too close to the character model and the animations will be cut off. also.. the trim trims around the object it sees and removes the unused area of the images.. so this wont work as the image will change each frame thus giving me 700 images each with different sizes

so cropping the image without using anything that is content aware has to be the way to go

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T17:36:50-07:00
by snibgo
Is this for an animated GIF? Or for one GIF per image? If it's for animated GIF, don't trim each individual frame, because then the animation will jump around. Instead, use "-layers optimize" on the overall GIF.

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T17:43:07-07:00
by BajungaDustin
snibgo wrote:Is this for an animated GIF? Or for one GIF per image? If it's for animated GIF, don't trim each individual frame, because then the animation will jump around. Instead, use "-layers optimize" on the overall GIF.

Yeah one Gif... and you are correct.. i kinda worked that out in me head when i tested a mogrify -trim... the image would definately jump around.

but im not sure what tou mean by layer optimize.. on the overall gif.. what exactly will that do.

and.. the gif comes out kinda crappy rright now because its sooo big. i almost think i need to trim it down before it goes into the gif because its realy sluggish... the above gif is a little too fast and its only half of the frames (the odd frames only)

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T17:47:52-07:00
by BajungaDustin
the layers optimize made it all kinds of jacked up.. leaving image ghosts but only like every 2 seconds or so.

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T18:08:21-07:00
by snibgo
Let's start again. What version of IM are you using? "convert -version" will tell you. You are on Windows 10, that's fine.

You have a load of stills, and want an animated GIF. Is that correct? If the stills contain a constant background, that won't take much filespace.

You said:
The current Gif is working but its 50 MB
What command did you use?

Re: Trimming Transparent Spaces in Bulk

Posted: 2016-06-30T18:12:12-07:00
by BajungaDustin
snibgo wrote:Let's start again. What version of IM are you using? "convert -version" will tell you. You are on Windows 10, that's fine.

You have a load of stills, and want an animated GIF. Is that correct? If the stills contain a constant background, that won't take much filespace.

You said:
The current Gif is working but its 50 MB
What command did you use?
Something like...

Code: Select all

 "convert -delay 1.5 -loop 1 00*.png animated.gif"
I think i managed to get all the images down to the correct crop tho..
Which was using

Code: Select all

Convert 00*.png -crop 400x640+750+-40 +Repage Cropped.png
which seems to have worked how i needed it to.
Image