1

Say I have an image of width 1000. I need to slice the image into 100 slices ,which will generate 100 images. Each one of the 100 images must be of length 10 * (slice number), so that it will contain all the previous parts as well.

So slice 1 will contain the first 1/100 of the initial image, slice 2 the 2/100 etc.

Is there a way to do this on Photoshop,using an online tool or any other program/library?

  • Have you tried the Slice Tools in Photoshop? – Scott Mar 20 '15 at 20:24
  • To slice,yes, but how do I export the images as needed? As far as I tried Photoshop only exports 100 equally sized images. – abinop Mar 20 '15 at 20:27
  • Your'e question is very unclear then. -- " I need to slice the image into 100 slices ,which will generate 100 images." – Scott Mar 20 '15 at 20:31
  • This is just an excerpt from the body of the question.I even tried to make the title clear so not to be confusing.If you think that the question can be asked better feel free to edit the question. – abinop Mar 20 '15 at 20:36
2

This may be a case for a batch solution.

By using the ImageMagick crop by percent function we can crop an image any given percentage from 1% to 100%.

Images below were cropped with the following command:

convert <input> -crop <x>%x0+0+0 <out>

Where <input> is the source image name, <x> is the precentage, and <out> it the output filename.

enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here
Cropped with <x> = 1, 10, 20, 30, 40, 50
enter image description here enter image description here
Cropped with <x> = 60, 70
enter image description here
Cropped with <x> = 80
enter image description here
Cropped with <x> = 90
enter image description here
Cropped with <x> = 100 (this was the source image)

Of course this need not be done manually but can easily be included in a script.

On a POSIX OS the following Bash script will produce 100 stacked slices (like above) starting at 1% to 100% and write these as out-<x>.jpg in the same directory from an image $1 given as a command line parameter.

#! /bin/bash

# $1 filename

for ((i=100; i>=1; i--)); do
    echo "$i"
    convert "$1" -crop $i%x0+0+0 "out-$i.jpg"
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.