CentOS system operation, ImageMagick is a picture processing tool, can be used to compress the size of the picture, then how to use ImageMagick to process pictures under CentOS? The following small series will introduce you to CentOS using ImageMagick to compress the size of the image in batches. Let's learn together. Installation of free images to use powerful tool ImageMagick
Centos system in line that can be used
a more useful commands:
yum install ImageMagick
Enter y to confirm the installation is complete
Next call the system command
The code is as follows:
#include "stdio.h"
Int main()
{
printf(“Please install ImageMagick before run this programme , else it will not run correctlyn”);
system(“mkdir small&rdquo ;);
system(“cp *.jpg ./small”);
system(“find./small -name ‘*.jpg’ -exec convert -resize 300×300 {} {} \\;”);
system(“pwd”);
system(“rename .jpg _small.jpg small/*.jpg”) ;
printf(“nConvert pictures finished,plesae check itn”);
return 0;
}
The resize parameter in the above convert can modify imagemagick, which can perform image conversion, size compression, and watermark on the image without having to write a third-party program. Just write a simple SHELL script. Complete the image compression operation, then introduce it on UBUNTU:
Installation command:
sudo apt-get install imagemagick
Other linux has corresponding software installation commands, the following I wrote two scripts for batch formatting and compression of images:
Image format conversion, the example here is a file in [bB][mM][pP] (all BMP files) format. Convert to a small jpg file:
The code is as follows:
#! /bin/sh
for img in `find. /-name “*.[bB][mM][pP]“`; do
#change upper filename to lower
_imglower=`echo $img|
Tr “[:upper:]” “[:lower:]“`;
#get file’s basename
_basename=`basename $_imglower .bmp`;< Br>
#get file’s dir
_dirname=`dirname $img`;
#get desc filename with path
_basefullname=$_dirname”/&rdquo ;$_basename”.jpg”;
#do convert
convert $img $_basefullname;
#remove bmp file
rm $img;< Br>
echo “deal $_basefullname successfully”;
done
Image compression script:
The code is as follows:
for img in ` Find. /-name “*.[jJ][pP][gG]“`; do
convert -resize 85%*85% $img $img-resized;
rm $ Img;
mv $img-resized $img
echo $img
done
for img in `find . /-name “*.[pP][nN][gG]“`; do
convert -resize 85%*85% $img $img-resized;
rm $ Img;
mv $img-resized $img
echo $img
done
for img in `find . /-name “*.[gG][iI][fF]“`; do
convert -resize 85%*85% $img $img-resized;
rm $ Img;
mv $img-resized $img
echo $img
done
The above is how to use ImageMagick to compress image size in batches under CentOS Introduced, after installing the ImageMagick tool, you can use the image compression script to compress the image size.
Using a Microsoft mouse under Windows is very simple. The Microsoft mouse has 5 but
In the Linuxp system, the itables command can perform a backup or restore for us, b
In Linux systems, VLANs, Layer 3 switching, and trunks are three confusing concepts
If the Linux system crashes, the data inside will be lost. Serious damage to the database, learn how
Linux system shell command tutorial
How to install LAMP in yum in CentOS6.5 system
Ubuntu shutdown can not shut down how to solve?
Linux how to use ControlPersist to speed up SSH connection speed
Linux svn error Cant convert string from how to do?
How to choose qcow2 and raw image format for Linux system
Summary of lftp usage in Linux system
Two classifications of Linux system commands
Linux uses Tmux to improve the efficiency of terminal operations.
How to kill pscan2 Trojan under Linux?
How to view information about Linux loading built-in modules
Win8 system can not connect to the router solution
Win8 system to automatically set the time synchronization method tutorial
How close the family group exit system Win8.1 family group
How to change the Windows 8 Consumer Preview Start Menu View
Windows 7 Colorful Theme Customization and Sharing
Ten recommendations for the official version of Win 8
How to upgrade Win8 to Win8.1 Preview
Personalized security optimization for Windows7 system (1)
Win10 implements the method of dragging files to automatically create folders
How to quickly uninstall and restore the gadgets that come with win7