
20 以上のフォルダーに 4500 以上の PNG 24 画像があり、それらを PNG 8 に変換してサイズを縮小したいと考えています。(余談ですが、スマッシングやその他の PNG 最適化を試しましたが、節約効果は十分ではありませんでした。PS の 2 つのフォルダーのテストでは、PNG 8 では画像が大幅に劣化しないことがわかりました)
PS CS3 バッチを試したところ、元のファイルを上書き保存できず、作成された新しいファイルにはフォルダー構造がありません。これを修正する方法や、この作業に適した別のツールはありますか?
私は OSX を実行していますが、Windows XP/7 にもアクセスできます。
答え1
表示バッチ処理/変換を処理します。Ctrl+ U: 「ツール -> バッチ処理...」
- 上書き、元のパスの使用(出力として)、および/またはサブフォルダー構造の保持のオプション。
- 「変換」タブから「変換 > カラーに変換」変換を追加します。パラメータの 1 つはビット/ピクセルです。
答え2
それは面倒ですよね? ここにコツがあります。アクションを記録して png8 にした後、アクション パレットの右上隅をクリックして、メニュー項目の挿入を選択します。次に、ファイル --> 保存をクリックします。[OK] をクリックします。これで、アクション内の最後のサブ項目になります。
これで、バッチを実行すると、内容は想定どおりにサブフォルダー内に残ります。
答え3
ImageMagickをインストールし、Powershellで実行する
#--------------------------------------------------------------------
# Powershell script to recursively convert image formats
# Configuration
$srcfolder = "C:\test\Animals"
$destfolder = "C:\test\Animals"
#This ps1 file will add copy files to designated folder
#Do NOT use Mogrify or the original images will be deleted
$im_convert_exe = "convert.exe -density 300"
# with VECTOR files the density setting should come BEFORE the vector file
# or the image will be blurry.
# change src_filter to the format of the source files
$src_filter = "*.eps"
# change dest_ext to the format of the destination files
$dest_ext = "png"
$options = "-depth 8 -alpha off"
$logfile = "C:\temp\convert.log"
$fp = New-Item -ItemType file $logfile -force
$count=0
foreach ($srcitem in $(Get-ChildItem $srcfolder -include $src_filter -recurse))
{
$srcname = $srcitem.fullname
# Construct the filename and filepath for the output
$partial = $srcitem.FullName.Substring( $srcfolder.Length )
$destname = $destfolder + $partial
$destname= [System.IO.Path]::ChangeExtension( $destname , $dest_ext )
$destpath = [System.IO.Path]::GetDirectoryName( $destname )
# Create the destination path if it does not exist
if (-not (test-path $destpath))
{
New-Item $destpath -type directory | Out-Null
}
# Perform the conversion by calling an external tool
$cmdline = $im_convert_exe + " `"" + $srcname + "`"" + $options + " `"" + $destname + "`" "
#echo $cmdline
invoke-expression -command $cmdline
# Get information about the output file
$destitem = Get-item $destname
# Show and record information comparing the input and output files
$info = [string]::Format( "{0} `t {1} `t {2} `t {3} `t {4} `t {5}", $count,
$partial, $srcname, $destname, $srcitem.Length , $destitem.Length)
echo $info
Add-Content $fp $info
$count=$count+1
}
#--------------------------------------------------------------