Skip to content

Instantly share code, notes, and snippets.

@Songmu
Created July 1, 2015 07:07
Show Gist options
  • Select an option

  • Save Songmu/06d4370a1d5c68e3691b to your computer and use it in GitHub Desktop.

Select an option

Save Songmu/06d4370a1d5c68e3691b to your computer and use it in GitHub Desktop.
DPI直すやつ
#!/usr/bin/env perl
use 5.014;
use warnings;
my $file = $ARGV[0];
system qw/sips -d profile --deleteColorManagementProperties/, $file;
my $dpiWidth = `sips -g dpiWidth $file | awk '/:/ {print \$2}'`;
my $dpiHeight = `sips -g dpiHeight $file | awk '/:/ {print \$2}'`;
my $pixelWidth = `sips -g pixelWidth $file | awk '/:/ {print \$2}'`;
my $pixelHeight = `sips -g pixelHeight $file | awk '/:/ {print \$2}'`;
if ($dpiWidth > 72.0 && $dpiHeight > 72.0) {
my $width = $pixelWidth * 72.0 / $dpiWidth;
my $height = $pixelHeight * 72.0 / $dpiHeight;
system qw/sips -s dpiWidth 72 -s dpiHeight 72 -z/, $height, $width, $file;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment