I have multiple small tables saved as PDF, and I would like to merge them together vertically into a one page PDF file. There is a lot of white space below each table, so merging them into a one page PDF is not placing them close to each other vertically. I would like to have a small amount of space between each table, and not approximately a full page of space between them. I have tried everything below with a mix of results.
This places everything side by side, and not what I want:
montage fig1.pdf fig2.pdf fig3.pdf final.pdf
This places each fig on a separate page, and not what I want:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=final.pdf fig1.pdf fig2.pdf fig3.pdf
This is nicer resolution and puts everything on the same page, but unfortunately keeps the massive white space under the table, which makes for a very long PDF page:
convert -density 150 fig1.pdf fig2.pdf fig3.pdf -append -trim +repage final.pdf
Is there a way I can specify to grab the first so many vertical pixels for each of the figs, and append those to the final PDF? Trim does a great job at removing white space around images, but it appears to only work for the right and left edges of the PDF figures versus all the edges.
Put your -trim +repage right after reading the pdf files and before -append. Add -gravity north so the pages are put to the top center. So try
convert -density 150 fig1.pdf fig2.pdf fig3.pdf -trim +repage -gravity north -append final.pdf
If you want some space between the pages, you can replace -append with -smush X. Where X is the the amount of space.
convert -density 150 fig1.pdf fig2.pdf fig3.pdf -trim +repage -gravity north -smush 20 final.pdf
Change the 20 to whatever you want. If you put at 0, then it is the same as -append.
Related
I want to split some images by percentage using ImageMagick.
To be more precise, I want to split an image into two images. The output-image of the left side should be 55% of the left side of the original image, the output-image of the right side should be 55% of the right ride of the original image.
(In case I am not making myself clear: The point is that there is sometimes important information in the middle of the images and this information would be cut off if we split the images exactly in the middle.)
What I have so far is this: mogrify -crop 55%x100% +repage -path ./cropped *.jpg
So at the moment, I am splitting the image into two and saving it in the "cropped"-folder. BUT, only the left side is 55% of the left side of the original image, the right side is 45% of the right side of the original image.
As this is my first time working with ImageMagick, I would really appreciate your help!
Here is another approach to splitting an image to create two output images that are 55% from the left and 55% from the right of the original...
convert input.png -set filename:0 "%[t]" \
\( +clone -roll +55+0% \) -extent 55x100% "%[filename:0]_%d.png"
That starts by setting a file name variable to use for the output. Then it makes a clone of the input image, and rolls it 55% to the right. The result is moving the rightmost 55% of the image out of the frame to the right and back into the frame on the left. Then after the parentheses a simple -extent operation keeps the leftmost 55% of each image. The output files are named from the input file with a "_0" or "_1" added.
As fmw42 suggested, you can make a loop command to run on multiple inputs, and include the path names in the command for your output files.
I think you would have to run a script loop over each image and use convert rather than mogrify. Mogrify can only output one image for each input image. You do not say what platform/OS or what version of ImageMagick. The following assumes Unix-like system with IM 6 and is one way to do that.
infile="original_file.suffix"
convert "$infile" -set filename:fname "%t" -write mpr:img +delete \
\( mpr:img -gravity west -crop 55x100%+0+0 +repage +write "path_to/cropped/%[filename]_0.suffix" \) \
\( mpr:img -gravity east -crop 55x100%+0+0 +repage +write "path_to/cropped/%[filename]_1.suffix" \) \
null:
Or, you could just run mogrify twice. Once for the left side and once for the right side. Use -gravity to control which as in the convert command.
I'm newbie, any help is appreciated. I'll keep it short.
What I'm doing now is "magick *.jpg -append a.png".
This merges 100+ of .jpg vertically into a .png. Problem is its long so I wanna split it in half so I get shorter a.png and b.png instead of 1 long .png.
I would like to have a single code that does it because there is hundreds of these folders.
You could use montage for that in ImageMagick.
magick montage *.jpg -tile 2x -geometry +0+0 result.png
If you want space between files, then change +0+0 to use non-zero amounts for the spacing. Montage can also add file names under the images if you want using -label %f in the command
I want to convert pdf pages to images of same size(aspect ratio maintained) irrespective of the pdf quality. Say A4 size. I am using convert from Imagemagick for this but struggling to get the fixed size of images for different pdfs of different quality.
Can anyone help me?
Something like:
convert -density 288 document.pdf -resize 2480x3508 result.png
The density must come before the PDF to ensure the rasterisation is done at sufficient quality/resolution.
If you want that centred on a piece of A4 and padded with white to fill the page:
convert -density 288 document.pdf -resize 2480x3508 -background white -gravity center -extent 2480x3508 result.png
I have several images with different sizes.
1.jpg
2.jpg
3.jpg
I need to arrange them on 1 layout in the following order:
1st image in the top-left corner
2nd in the middle
3rd in the middle
(as in the example: http://postimg.org/image/4wcf5l0gl/ )
I try smth like:
montage 1.jpg 2.jpg 3.jpg -mode concatenate -tile 1x3 out.jpg
but 2nd and 3rd appear on the left side.
You can easily do this with the convert program by a sequence of -append operations. In the simplest case:
convert 1.jpg 2.jpg -append 3.jpg -gravity center -append out.jpg
Note that order of operations goes from left to right with convert. I load two images, and append them together. Then I load image #3 and change the -gravity setting to center, to perform a centered append (instead of a "left justified" one). Last is the output filename.
You can add the text at the top by generating a label and putting a horizontal append (+append) in its proper place in the sequence:
convert 1.jpg label:'text from file-name' +append 2.jpg -append 3.jpg -gravity center -append out.jpg
To pad the images with space around them, use -border on each individual image before appending. You can use grouping parentheses to limit the effect of any operation to only certain images*:
convert 1.jpg label:'text from file-name' -bordercolor white -border 10 +append \( 2.jpg -border 10 \) -append \( 3.jpg -border 10 \) -gravity center -append out.jpg
You can get more and more elaborate from here. Just remember that order of operations proceeds from left to right, and operations can be limited to certain images by use of grouping parentheses.
*footnote: The syntax of the commands above assume a typical unix/linux shell environment. The syntax will have to be adapted if you are using some other environment.
i would like to add a series of images to existing one, using imagemagick command line.
i have this image: http://tinypic.com/r/313386r/6 and
i would like to add this to this one: http://tinypic.com/r/k0jbqs/6
to get more or less this effect: http://tinypic.com/r/wtja74/6 .
as you see, this is not only adding an image. i found http://www.imagemagick.org/Usage/compose/ where i could see some examples, but what i need is to fill each 'block'.
i have exact position where each block starts and ends, also i have a scale parameter to scale it down.
i think i could use
composite -geometry +31+105 toadd.gif source.gif newfile.jpg
but this is only one image added, and i need it scaled down.
i was wondering if i can create some kind of rectangles and fill them with my image.
any idea how it can be solved?
Convert would be better as you can keep adding images with composite or layers.
Here is a very rough example and I would probably start off with a longer section of wall so you could crop it when resizing. There is still going to be quite a bit of user input to fix the locations as I pressume you do not always have the same amount of walls at the same length.
I would write some code to input details into a form as it would be easier than altering the code each time.
convert k0jbqs.jpg \
( 313386r.png -thumbnail x25 ) -gravity west -geometry +0+30 -composite \
( 313386r.png -thumbnail x25 ) -gravity center -geometry +80+30 -composite \
( 313386r.png -thumbnail x25 ) -gravity east -geometry +0+30 -composite \
output.png
You would need to take the line breaks out I just added those to make the code readable.
NOTES: Thumbnail resizes the brick image; you can forget the gravity and just use -geometry and the numbers are the positions from the top left corner and -composite puts the new image over the previous image.