Script Library: 1247 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Archive version of: resizer.r ... version: 1 ... crazyaxe 22-Jul-2011

Amendment note: new script || Publicly available? Yes

Rebol [
Title: "Resizer" 
File: %resizer.r 
Author: "Massimiliano Vessi" 
Date: 2011-07-22 
Version: 1.1.1 
email: maxint@tiscali.it 
Purpose: {Simple image resizer} 
Library: [ 
	level: 'intermediate 
	platform: 'all 
	type: [tool demo ] 
	domain: [all] 
	tested-under: [view 2.7.8.3.1 Windows Linux ] 
	support: maxint@tiscali.it 
	license: 'gpl 
	see-also: none 
	]
]

max_L: 70
max_H: 70
suff: "_small"



ridimensiona:  does [
	immagini: request-file	
	foreach immagine_f   immagini [ 
		immagine_i: load-image immagine_f
		temp_imm: load-image immagine_f ;we'll use this for height check		
		if x/data [
			dimensioni: immagine_i/size
			if dimensioni/1 > max_L [
				fattore:  dimensioni/1 / max_L   
				temp_L:  layout/tight [ image (dimensioni / fattore) immagine_i ] 
				temp_imm: to-image temp_L ;this will be used for heigh check
				save/png (to-file rejoin [  immagine_f  suff_f/text ".png" ]) temp_imm
				]
			]
		if y/data [
			dimensioni: temp_imm/size ;this way, we'll use the X resized image or the original image
			if dimensioni/2 > max_H [
				fattore:  dimensioni/2 / max_H   
				temp_L:  layout/tight [ image (dimensioni / fattore) immagine_i ] 
				temp_imm: to-image temp_L
				save/png (to-file rejoin [  immagine_f  suff_f/text ".png" ]) temp_imm
				]
			]

		]
	alert "DONE!"	
	]	


help_L: layout [ 
	title "Help"
	text 250 {This is software aims to create small copy of the original images, resize the to smaller size.
		You can choose what dimensions use, if software should check just length or height or both.
		You can select multiple files at one time.
		You can choose the suffix to append at the new images.
		If you need further help, you can contact me:}
	text (rejoin [ "maxint" "@" "tiscali.it" ])
	]


view layout [ 
	title "THUMBNAIL GENERATOR"
	across 
	x: check true
	text "Max Leight:" 
	maxL: field (to-string max_L)
	return
	y: check
	text "Max Height:" 
	maxL: field (to-string max_H)
	return
	text "Suffix:" 
	suff_f: field suff ;ths suffix to append at the file names of thumbnail immages
	return
	button "Select image(s)" [ ridimensiona ]
	btn-help [ view/new help_L ]
	]