Situation: start browsing of the figures at width 1:960 and height full in Terminal
Motivation: Ubuntu's default image viewer opens the figure at full width and full height, making the browsing of very wide figures difficult; its CTRL
+ -
of the full picture is not enough whene you iterate many pictures where width x height
Differential conditions: To Adjust Brightness-Contrast in Plane with Gimp/ImageMagick/…?, ...
Image Resolution as Width x Height and Margins in pixels at each iteration
Iteration Image Resolution Left Right Top Bottom
1 960 x 960 110 80 70 100
2 960 x 1920 230 180 70 100
3 960 x 2880 350 280 70 100
4 960 x 3840 470 380 70 100
5 960 x 4800 590 480 70 100
6 960 x 5760 710 580 70 100
7 960 x 6720 830 680 70 100
8 960 x 7680 950 780 70 100
9 960 x 8640 1070 880 70 100
10 960 x 9600 1190 980 70 100
% whtyger and Gimp use to find out the margins http://askubuntu.com/a/803012/25388
Dummy test data of Image Resolution 960x1920 at 2nd iteration, 960x4800 at 5th iteration, 960x8640 at 9th iteration, and Resolution 960x9600 at 10th iteration, respectively
My pseudocode
#!/bin/bash
OUTRES=$1
ITER=$2
IMAGE=$3
top=70
height=960
width=$(( 960*${ITER} ))
left=$(( 110+${ITER}*120 ))
right=$(( 80+${ITER}*100 ))
x=$(( ${width}-${left}-${right} ))
y=$(( ${height}-${bottom}-${top} ))
display -geometry ${OUTRES}x${OUTRES} \
-extract ${x}x${y}+${left}+${top} "$IMAGE"
Attempt with unstable margins with display
and extract
whtyger's code works but it has some unstable margins i.e. their size differs depending on the image, here 5th iteration
- At Right-hand-side picture, you see that not all text of the colorbar is included in the output.
- At Left-hand-side picture, you see the margin_left is not equal to margin_top.
Reason: MARGIN_T
, MARGIN_B
, MARGIN_L
, MARGIN_R
Fix: use scientific numbering with larger iterations or increase MARGIN_R
; some adjustments in the code
MARGIN_T=60
MARGIN_B=90
MARGIN_L=$(( -5 + $ITER * 119 ))
MARGIN_R=$(( -20 + $ITER * 95 ))
Output: some margin around the data always
Reviewing whtyger's comment for attempt of no margins with convert
and crop
To get rid of margins completely you can modify the original image. Use convert image.png -crop SIZE_XxSIZE_Y+SHIFT_X+SHIFT_Y > edited.png and then use any viewer you like. You can adapt my script for that, just replace display+-extract with convert+-crop.
I replace the last line by the following but unsuccessful output
convert "$IMAGE" -crop ${EXTRACT_X}x${EXTRACT_Y}+${MARGIN_L}+${MARGIN_T} \
"${IMAGE%.png}_cropped.png"
display -geometry ${OUTRES}x${OUTRES}+${SHIFT}+${SHIFT} \
-extract ${EXTRACT_X}x${EXTRACT_Y}+${MARGIN_L}+${MARGIN_T} \
"${IMAGE%.png}_cropped.png"
rm "${IMAGE%.png}_cropped.png"
Output: about 1 px margin in all directions, left margin chops some info from numbers of >= 1000.
System: Linux Ubuntu 16.04 64 bit
Hardware: Macbook Air 2013-mid
Cntrl
+-
to view the whole picture?