Add scripts for managing images
This commit is contained in:
		
							parent
							
								
									334633b16f
								
							
						
					
					
						commit
						3a3210fc99
					
				
					 2 changed files with 49 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								bin/imageResizeFolder
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										27
									
								
								bin/imageResizeFolder
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| #!/usr/bin/env bash | ||||
| # Purpose: batch image resizer | ||||
| 
 | ||||
| # absolute path to image folder | ||||
| FOLDER="$PWD" | ||||
| 
 | ||||
| # max height | ||||
| WIDTH=${1:-"999999"} | ||||
| 
 | ||||
| # max width | ||||
| HEIGHT=${2:-"999999"} | ||||
| 
 | ||||
| echo "Width: $WIDTH"; | ||||
| echo "Height: $HEIGHT"; | ||||
| 
 | ||||
| #resize png or jpg to either height or width, keeps proportions using imagemagick | ||||
| #find ${PWD} -iname '*.jpg' -o -iname '*.png' -exec echo convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{}.new.jpg \; | ||||
| find ${PWD} \( -iname "*.jpg" -o -iname "*.png" \) -exec convert {} -verbose -resize "$WIDTH"x"$HEIGHT" \{}.new \; | ||||
| 
 | ||||
| #resize png to either height or width, keeps proportions using imagemagick | ||||
| #find ${FOLDER} -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \; | ||||
| 
 | ||||
| #resize jpg only to either height or width, keeps proportions using imagemagick | ||||
| #find ${FOLDER} -iname '*.jpg' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \; | ||||
| 
 | ||||
| # alternative | ||||
| #mogrify -path ${FOLDER} -resize ${WIDTH}x${HEIGHT}% *.png -verbose | ||||
							
								
								
									
										22
									
								
								bin/lanPortImages
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										22
									
								
								bin/lanPortImages
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| #!/usr/bin/env bash | ||||
| 
 | ||||
| mkdir "portraits" | ||||
| mkdir "landscapes" | ||||
| for f in ./*.jpg; do | ||||
| 	WIDTH=$(identify -format "%w" "$f")> /dev/null | ||||
| 	HEIGHT=$(identify -format "%h" "$f")> /dev/null | ||||
| 	echo "Width: $WIDTH" | ||||
| 	echo "Height: $HEIGHT" | ||||
| 	echo "" | ||||
| 	if [[ "$HEIGHT" > "$WIDTH" ]]; then | ||||
| 		mv "$f" portraits/ | ||||
| 	else | ||||
| 		mv "$f" landscapes/ | ||||
| 	fi | ||||
|     #if file "$f" 2>&1 | awk '/w =/{w=$5+0; h=$7+0; if (h>w) exit; else exit 1}' | ||||
|     #then | ||||
|     #    mv "$f" portraits/ | ||||
|     #else | ||||
|     #    mv "$f" landscapes/ | ||||
|     #fi | ||||
| done | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue