如何轻松调整图像大小?
我想在 ubuntu 14.04 LTS 上使用该方法转换我的图像
首先安装 imagemagick
sudo apt-get install imagemagick
打开终端并运行以下命令:
convert -resize 50% source.png dest.jpg
它将尺寸缩小50%
您还可以指定尺寸:
convert -resize 1024X768 source.png dest.jpg
但得到了这个输出:
$ convert -resize 40% DSC_9702 copy.jpg dest.jpg
The program 'convert' can be found in the following packages:
* imagemagick
* graphicsmagick-imagemagick-compat
Try: sudo apt-get install <selected package>
$ sudo apt-get install imagemagick
[sudo] password for educ:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
imagemagick-common libfftw3-double3 libilmbase6 liblqr-1-0 libmagickcore5
libmagickcore5-extra libmagickwand5 libnetpbm10 libopenexr6 netpbm
Suggested packages:
imagemagick-doc autotrace curl enscript ffmpeg gimp gnuplot grads hp2xx
html2ps libwmf-bin mplayer povray radiance texlive-base-bin transfig
ufraw-batch libfftw3-bin libfftw3-dev
The following NEW packages will be installed:
imagemagick imagemagick-common libfftw3-double3 libilmbase6 liblqr-1-0
libmagickcore5 libmagickcore5-extra libmagickwand5 libnetpbm10 libopenexr6
netpbm
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,015 kB of archives. After this operation, 15.1 MB of additional disk space will be used. Do you want to continue? [Y/n] y
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main imagemagick-common all 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libfftw3-double3 i386 3.3.3-7ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libilmbase6 i386 1.0.1-6ubuntu1 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main liblqr-1-0 i386 0.4.1-2ubuntu1 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libmagickcore5 i386 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libmagickwand5 i386 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libopenexr6 i386 1.6.1-7ubuntu1 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libmagickcore5-extra i386 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main imagemagick i386 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libnetpbm10 i386 2:10.0-15ubuntu2 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main netpbm i386 2:10.0-15ubuntu2 Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/imagemagick-common_6.7.7.10-6ubuntu3_all.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/f/fftw3/libfftw3-double3_3.3.3-7ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/ilmbase/libilmbase6_1.0.1-6ubuntu1_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/libl/liblqr/liblqr-1-0_0.4.1-2ubuntu1_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/libmagickcore5_6.7.7.10-6ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/libmagickwand5_6.7.7.10-6ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/o/openexr/libopenexr6_1.6.1-7ubuntu1_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/libmagickcore5-extra_6.7.7.10-6ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/imagemagick_6.7.7.10-6ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/n/netpbm-free/libnetpbm10_10.0-15ubuntu2_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/n/netpbm-free/netpbm_10.0-15ubuntu2_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
$ sudo apt-get install imagemagick
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
imagemagick-common libfftw3-double3 libilmbase6 liblqr-1-0 libmagickcore5
libmagickcore5-extra libmagickwand5 libnetpbm10 libopenexr6 netpbm
Suggested packages:
imagemagick-doc autotrace curl enscript ffmpeg gimp gnuplot grads hp2xx
html2ps libwmf-bin mplayer povray radiance texlive-base-bin transfig
ufraw-batch libfftw3-bin libfftw3-dev
The following NEW packages will be installed:
imagemagick imagemagick-common libfftw3-double3 libilmbase6 liblqr-1-0
libmagickcore5 libmagickcore5-extra libmagickwand5 libnetpbm10 libopenexr6
netpbm
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,015 kB of archives. After this operation, 15.1 MB of additional disk space will be used. Do you want to continue? [Y/n] y
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main imagemagick-common all 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libfftw3-double3 i386 3.3.3-7ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libilmbase6 i386 1.0.1-6ubuntu1 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main liblqr-1-0 i386 0.4.1-2ubuntu1 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libmagickcore5 i386 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libmagickwand5 i386 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libopenexr6 i386 1.6.1-7ubuntu1 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libmagickcore5-extra i386 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main imagemagick i386 8:6.7.7.10-6ubuntu3 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main libnetpbm10 i386 2:10.0-15ubuntu2 Could not resolve 'ma.archive.ubuntu.com'
Err http://ma.archive.ubuntu.com/ubuntu/ trusty/main netpbm i386 2:10.0-15ubuntu2 Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/imagemagick-common_6.7.7.10-6ubuntu3_all.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/f/fftw3/libfftw3-double3_3.3.3-7ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/ilmbase/libilmbase6_1.0.1-6ubuntu1_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/libl/liblqr/liblqr-1-0_0.4.1-2ubuntu1_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/libmagickcore5_6.7.7.10-6ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/libmagickwand5_6.7.7.10-6ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/o/openexr/libopenexr6_1.6.1-7ubuntu1_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/libmagickcore5-extra_6.7.7.10-6ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/imagemagick_6.7.7.10-6ubuntu3_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/n/netpbm-free/libnetpbm10_10.0-15ubuntu2_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Failed to fetch http://ma.archive.ubuntu.com/ubuntu/pool/main/n/netpbm-free/netpbm_10.0-15ubuntu2_i386.deb Could not resolve 'ma.archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
$ convert -resize 40% DSC_9702 copy.jpg dest.jpg
The program 'convert' can be found in the following packages:
* imagemagick
* graphicsmagick-imagemagick-compat
Try: sudo apt-get install <selected package>
答案1
我觉得你的网络配置似乎有问题,但是你仍然可以使用主机名 ping 存档服务器,这让我有点困惑......
无论如何,我建议您通过以下方式添加备用 DNS 服务器(由 Google 提供):
sudo sh -c "echo nameserver 8.8.8.8 >> /etc/resolvconf/resolv.conf.d/base"
sudo sh -c "echo nameserver 8.8.4.4 >> /etc/resolvconf/resolv.conf.d/base"
并使你的更改生效:
sudo resolvconf -u
之后,运行sudo apt-get update && sudo apt-get install imagemagick
安装 imagemagick 包。然后您就可以使用该convert
命令了。
有关使用 NetworkManager 配置的详细说明和说明可在本文中找到:“sudo echo nameserver 8.8.8.8 > /etc/resolv.conf” 有什么作用?
参考: