Deseo hacer esto en CLI con un comando genérico (porcentaje, no ancho y alto reales).
Puedes hacerlo imagemagick
escribiendo lo siguiente:
convert image.png -resize 50% -density 72 image.png
Para poder ejecutar el comando anterior necesitas imagemagick
instalarlo en tu computadora. Puedes hacerlo fácilmente a través de homebrew :
brew install imagemagick
Y, si no tienes homebrew, puedes instalar con esto:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Echa un vistazo al comando 'sips':
man sips
Es mucho más simple que la vista previa de secuencias de comandos GUI y es parte de OSX. Así que no tienes que instalar nada. Ejemplo:
full_w=$(/usr/bin/sips -g pixelWidth image.jpg | /usr/bin/grep -Eo "[[:digit:]]+")
full_h=$(/usr/bin/sips -g pixelHeight image.jpg | /usr/bin/grep -Eo "[[:digit:]]+")
half_w=$(/bin/expr full_w / 2)
half_h=$(/bin/expr full_h / 2)
sips -z half_h half_w image.jpg
Aquí hay un applescript justo para lo que quería, se puede acoplar con automator o introducirlo en el programa de línea de comandos osascript así:
osascript << 'END'
{applescript here}
END
También puede agregarlo a su perfil ~/.bash como un alias para un comando, por lo que todo lo que tiene que hacer es ingresar el nombre del alias de reducción de tamaño y aparecerá, le preguntará qué archivo desea cambiar de tamaño, y lo hace. el resto automáticamente.
alias downsize="osascript << 'END'
{applescript here}
END"
Applescript:
tell application "Preview"
activate
try
open (choose file with prompt "Pick file to modify")
on error
display dialog "Invallid selection!"
return 1
end try
end tell
tell application "System Events" to tell process "Preview"
set frontmost to true
click (menu item 1 where its title starts with "Adjust Size") of menu of menu bar item "Tools" of menu bar 1
tell pop up button 1 of group 1 of sheet 1 of window 1
click
tell menu 1
click menu item "percent"
end tell
end tell
set value of text field 1 of group 1 of sheet 1 of window 1 to "50"
set value of text field 2 of group 1 of sheet 1 of window 1 to "50"
set value of text field 3 of group 1 of sheet 1 of window 1 to "72"
click button "OK" of sheet 1 of window 1
click (menu item 1 where its title starts with "Save") of menu of menu bar item "File" of menu bar 1
end tell
ignoring application responses
tell application "Preview" to quit
end ignoring
¡Espero que esto ayude!
Sibila
awado
PrimoCocaína
sips
es una buena respuesta ya que es nativo de OSX y ligero.imagemagick
Es bueno saber que es la navaja suiza para la manipulación de imágenes, pero podría ser demasiado pesado para cambiar el tamaño.Sibila