小编Jef*_*ski的帖子

jpegtran - 无损裁剪图像的左侧部分

我有一个 1400x1400 的图像,我想在其中向左修剪 4 个像素,在底部修剪 1 个像素,为了保持方形比例,从顶部修剪 3 个像素。问题是,每当我使用 进行裁剪时jpegtran,无论我做什么,都会从右下角删除像素。例如,仅测试左侧部分,我尝试过:

jpegtran -perfect -crop 1396x1400+0+0 -outfile crop.jpg image.jpg
Run Code Online (Sandbox Code Playgroud)

但这只是从右侧删除了 4 个像素;

jpegtran -perfect -crop 1396x1400-4+0 -outfile crop.jpg image.jpg
Run Code Online (Sandbox Code Playgroud)

这再次从右侧删除了 4 个像素;

jpegtran -perfect -crop 1396x1400+4+0 -outfile crop.jpg image.jpg
Run Code Online (Sandbox Code Playgroud)

并且根本不会删除任何像素;更一般地说,

jpegtran -perfect -crop 1396x1400+x+0 -outfile crop.jpg image.jpg

jpegtran -perfect -crop 1396x1400-x+0 -outfile crop.jpg image.jpg
Run Code Online (Sandbox Code Playgroud)

x0和4之间,不会分别取出从右侧4-x和x个象素。凭借x高于5,显然给出了一个错误。我无法实现任何左修剪。谁能帮我?

我使用的是jpegtranlibjpeg-turbo一个Arch Linux的x86_64的系统版本1.4.2(编译20151205)。

image-manipulation jpeg trim

5
推荐指数
1
解决办法
2538
查看次数

发出带有由条件决定的选项的命令

我正在尝试制作一个 shell 脚本,它会向用户提出一些问题,并将根据用户的选择发出带有某些或其他选项的最终命令。现在,脚本如下所示:

if [[ $a == "y" ]] ; then

    command --option 1 argument

elif [[ $a == "n" ]] ; then

    command --option 2 argument

else

    command --option 3 argument

fi
Run Code Online (Sandbox Code Playgroud)

考虑到该命令很长,并且包含许多在不同语句之间保持不变的选项和参数,我想知道是否可以以某种方式写一行,只有在相应的条件为真时才考虑可变选项。

这也适用于GNU parallel发出一个或多个命令

if [[ $b == "n" ]] ; then

    find ./ -name '*.extension' | parallel -j $(nproc) command1 --option argument

else

    find ./ -name '*.extension' | parallel -j $(nproc) command1 --option argument\; command2 --option argument
Run Code Online (Sandbox Code Playgroud)

bash options shell-script

2
推荐指数
1
解决办法
501
查看次数

标签 统计

bash ×1

image-manipulation ×1

jpeg ×1

options ×1

shell-script ×1

trim ×1