Want to resize images for a specific size on server - Please help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Want to resize images for a specific size on server - Please help
# 1  
Old 04-12-2014
,,,,,,

Last edited by Praveen Pandit; 04-16-2014 at 01:55 AM..
# 2  
Old 04-13-2014
Assuming that the directory /websites/www.abc.com/ROOT/uploads/inventory/100024/34510/110x85 already exists, what ImageMagick command would you use to resize /websites/www.abc.com/ROOT/uploads/inventory/100024/34510/400x300/34510-20140319-131033.jpeg into /websites/www.abc.com/ROOT/uploads/inventory/100024/34510/110x85/34510-20140319-131033.jpeg?

Are all of the jpeg and jpg files that you want to process located in directories matched by the pattern /websites/www.abc.com/ROOT/uploads/inventory/*/*/400x300? If not, how do you find the files you want to convert?
# 3  
Old 04-13-2014
,,,,,,,,

Last edited by Praveen Pandit; 04-16-2014 at 01:54 AM..
# 4  
Old 04-13-2014
This should give you a template you can use to get the variables you want. I use the Korn shell, but this will work with any shell that recognizes the shell variable expansions required by the POSIX standards (including bash and ksh):
Code:
#!/bin/ksh
IMAGES_HOME="/websites/www.abc.com/ROOT/uploads/inventory/"
find "$IMAGES_HOME" -type f \
    \( -name '*.[Jj][Pp][Gg]' -o -name '*.[Jj][Pp][Ee][Gg]' \) |
    grep -F /400x300/ | while read -r f
do	printf 'Processing: %s\n' "$f"
					# If f=/prefix/x/y/400x300/z.jpg
	file=${f##*/}			# x.jpg
	p3=${f%/*}			# /prefix/x/y/400x300
	d3=${p3##*/}			# 400x300
	p2=${p3%/*}			# /prefix/x/y
	d2=${p2##*/}			# y
	p1=${p2%/*}			# /prefix/x
	d1=${p1##*/}			# x
	printf 'file: %s\n' "$file"
	printf 'd1: %s\n' "$d1"
	printf 'd2: %s\n' "$d2"
	printf 'd3: %s\n' "$d3"
	printf 'p1: %s\n' "$p1"
	printf 'p2: %s\n' "$p2"
	printf 'p3: %s\n' "$p3"
	pd="$p2/110x85"			# /prefix/x/y/110x85
	printf 'pd: %s\n' "$pd"
	if [ ! -d "$pd" ]
	then	printf 'Creating directory: %s\n' "$pd"
		mkdir "$pd"
	fi
	dest="$pd/$file"		# /prefix/x/y/110x85/z.jpg
	printf 'dest: %s\n' "$dest"
done

This User Gave Thanks to Don Cragun For This Post:
# 5  
Old 04-13-2014
Thanks a lot Mr.Don Cragun. Your solution has helped me.

Regards
Praveen
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to download Images and Json file from server(godaddy) to Local machine (Ubuntu 14.04).?

Hi Guys, Just entering the Linux word, So I need help to write a script on my local machine(Ubuntu 14.04) that continuously check the particular folder(contains images) and a json file on the server and download whenever new images are added to that folder and whenever there is a change in the... (10 Replies)
Discussion started by: g4v1n
10 Replies

2. Shell Programming and Scripting

Bash Script to find/sort/move images/duplicate images from USB drive

Ultimately, I'm looking to create a script that allows me to plug in a usb drive with lots of jpegs on it & copy them over to a folder on my hard drive. So in the process of copying I am looking to hash check them, record dupes to a file, copy only 1 of the identical files (if it doesn't exsist... (1 Reply)
Discussion started by: JonaQuinn
1 Replies

3. Shell Programming and Scripting

How to find & auto resize images?

I need a command or mini scripts that can find certain type of images file recursively from the current dir with files of minimum 736 width and resize them by "736 max width, relative height" and replace the source files. I currently have GD installed but can also install Imagemagick if needed, I'm... (5 Replies)
Discussion started by: Frozen77
5 Replies

4. Red Hat

Fdisk reports the old size after disk resize

Hi, I'm running a Red Hat Enterprise Linux Server release 5.3 (Tikanga) on VMWare. It is a production system for which I may not get downtime soon. I happened to resize a underlying disk and the changes are not reflecting in the fdisk ouput. Further details are as follows. The disk which i... (3 Replies)
Discussion started by: maverick_here
3 Replies

5. Shell Programming and Scripting

resize images

Is there a script or extension that I can look into that will re-size an allotment of images to a given size?? Id like to take images of a certain size and resize them but Im dont remember an install option that can do it if installed in ubuntu but I, also unsure in what code I will have to learn.... (2 Replies)
Discussion started by: graphicsman
2 Replies

6. UNIX for Dummies Questions & Answers

Not Sure How to Look for Not Used Images On the Server

Hello All: I a website with over 1800 pages in all HTML and I am trying to figure out, what is the best way for me to see when the image files were last accessed. Reason being, I am sure I have images in there that were not deleted when a page was taken offline or whatever and I would like... (3 Replies)
Discussion started by: pmsquillace
3 Replies

7. UNIX for Advanced & Expert Users

How do I configure kickstart server to install different images

How do I configure kickstart server to install workstation using centos image and other workstation using redhat enterprise image. I configured my kickstart server to auto install centos 5.3 and it working fine. However I would like to configure kickstart server, so that workstation with... (1 Reply)
Discussion started by: hassan1
1 Replies

8. Shell Programming and Scripting

delete oldest images from remote server

Would someone please give me a script that will remove all but the newest jpg image from my server. i am uploading a new image every 10 seconds form a live web cam Also i do not know who to make a shell script work i am new to all this so i need all the help you could give Thank You very much (1 Reply)
Discussion started by: Destined
1 Replies

9. UNIX Desktop Questions & Answers

Resize the default window size

Hi, How can I resize the terminal window's default size in CDE (Solaris)? Regards, Sharif. (1 Reply)
Discussion started by: sharif
1 Replies

10. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies
Login or Register to Ask a Question