"sips" Command (with examples)
- Osx
- November 5, 2023
1: Specify an output directory so that originals do not get modified
sips --out path/to/out_dir
Motivation: This command allows you to specify an output directory for the processed images. By doing so, you can ensure that the original images are not modified, and the processed copies are saved to the specified directory.
Explanation: The --out
option followed by the path to the output directory specifies where the processed images should be saved. The path can be absolute or relative to the current directory.
Example Output: If the command is executed successfully, the processed image(s) will be saved to the specified output directory without modifying the original image(s).
2: Resample image at specified size (altering aspect ratio)
sips --resampleHeightWidth 1920 300 image_file.ext
Motivation: This command allows you to resample an image to a specified height and width. It can be useful when you need to resize an image while potentially altering its aspect ratio.
Explanation: The --resampleHeightWidth
option followed by the desired height (1920) and width (300) specifies the new dimensions for the image. The image_file.ext
argument represents the path to the image file that you want to resample.
Example Output: The image will be resampled to the specified height and width. Depending on the original aspect ratio, the resulting image may not have the same proportions as the original.
3: Resample image to fit within specified size (maintaining aspect ratio)
sips --resampleHeightWidthMax 1920 300 image_file.ext
Motivation: This command allows you to resample an image by ensuring that its height and width do not exceed the specified size, while maintaining the original aspect ratio.
Explanation: The --resampleHeightWidthMax
option followed by the maximum height (1920) and width (300) specifies the size boundaries for the image. The image_file.ext
argument represents the path to the image file that needs to be resampled.
Example Output: The image will be resampled so that its height and width do not exceed the specified maximum values. The resulting image will maintain the original aspect ratio, but its dimensions may be smaller than the specified size if the original image was already smaller.
4: Resample all images in a directory to fit a specific width (maintaining aspect ratio)
sips --resampleWidth 960 path/to/images
Motivation: This command can be used to resize all images in a directory to fit a specific width, while preserving the aspect ratio. It is convenient when you want to process multiple images at once.
Explanation: The --resampleWidth
option followed by the desired width (960) specifies the new width for the images. The path/to/images
argument represents the directory containing the images to be resampled.
Example Output: All the images within the specified directory will be resampled so that their width does not exceed 960 pixels. The resulting images will maintain the original aspect ratio.
5: Convert an image from CMYK to RGB
sips --matchTo "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc" path/to/image.ext path/to/out_dir
Motivation: This command allows you to convert an image from the CMYK color mode to the RGB color mode. Converting an image to RGB can be beneficial for various purposes, such as web display or compatibility with RGB-based software.
Explanation: The --matchTo
option followed by the path to the RGB ICC profile ("/System/Library/ColorSync/Profiles/Generic RGB Profile.icc") specifies the desired color profile for the output image. The path/to/image.ext
argument represents the path to the input image, and path/to/out_dir
specifies the output directory.
Example Output: The image will be converted from the CMYK color mode to the RGB color mode with the specified ICC profile applied. The resulting image will be saved in the specified output directory.
6: Remove ColorSync ICC profile from an image
sips --deleteProperty profile --deleteColorManagementProperties path/to/image_file.ext
Motivation: This command can be used to remove the ColorSync ICC profile from an image. Removing the ICC profile may be necessary in certain scenarios, such as when you want to remove color transformations or ensure consistent rendering across devices.
Explanation: The --deleteProperty
option followed by “profile” specifies that the ICC profile should be deleted. The --deleteColorManagementProperties
option ensures that all color management properties associated with the image are removed. The path/to/image_file.ext
argument represents the path to the image file from which the ICC profile should be removed.
Example Output: The ICC profile and all color management properties will be removed from the image file, resulting in a file without any associated color transformations or properties.