0

How to easily resize images?

I want to use that method on ubuntu 14.04 LTS to convert my image

First install imagemagick

sudo apt-get install imagemagick

Open a terminal and run this command:

convert  -resize 50% source.png dest.jpg

It will reduce the size by 50%

You can also specify the size:

convert  -resize 1024X768  source.png dest.jpg

enter image description here

but got this output:

$ 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>
David Foerster
  • 36,264
  • 56
  • 94
  • 147
Educ
  • 109
  • 1
  • 7

1 Answers1

2

I think there seems to be something wrong with your network configuration, however, you could still ping the archive server with its hostname, which make me a little bit confused...

Anyway, I would suggest you to add alternative DNS servers (provided by Google) by:

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"

And make your changes to take effect with:

sudo resolvconf -u

After that, run sudo apt-get update && sudo apt-get install imagemagick to install the imagemagick package. And you will be able to use the convert command.

Detailed explanation and instruction for configuring this with NetworkManager could be found in this article: What does "sudo echo nameserver 8.8.8.8 > /etc/resolv.conf" do?

Reference:

  1. Persist dns nameserver for ubuntu 14.04
  2. How do I set my DNS on Ubuntu 14.04?
P.-H. Lin
  • 2,824