我在寻找使photoshop的行动(也许这是不可能的,任何其他应用程序的建议将是有益的)。我想要一个照片集和使它们的某些方面的口粮,例如:4:3.

所以我有一个图像就是个150像素的广泛的由200像素较高。我想发生的情况是图像的画布是为了能267px宽,与新的区域充满了某种颜色。

因此有两种可能性,我可以认为:

1)Photoshop的行动可能这样做,但我会拉当前的高度,乘以1.333333然后把这个价值在宽度框画布的调整。是否有可能计算出的价值在Photoshop的行为?

2)一些其他应用程序有这个功能。

任何帮助是极大的赞赏。

有帮助吗?

解决方案

哇,我现在看到的(后编写的答案),这是要求一个长时间以前。..哦,好的。这个脚本没有把戏。

这Photoshop脚本将调整任何图像的画布所以,它已经4:5方面的比例。你可以改变的方面比例适用可通过改变arWidth和arHeight.填充色将设置到当前的背景的颜色。你可以创建一个行动的打开一个文件,应用这个脚本,然后关闭该文件做一批过程。

关闭Photoshop。
复制这javascript入一个新的文件,名为"调整的画布上。代码"Photoshop的预设\脚本文件夹。
开始Photoshop和在该文件的脚本菜单,它应该出现。

#target photoshop

main ();

function main ()
{
    if (app.documents.length < 1)
    {
        alert ("No document open to resize.");
        return;
    }

    // These can be changed to create images with different aspect ratios.
    var arHeight = 4;
    var arWidth = 5;

    // Apply the resize to Photoshop's active (selected) document.
    var doc = app.activeDocument;

    // Get the image size in pixels.
    var pixelWidth = new UnitValue (doc.width, doc.width.type);
    var pixelHeight = new UnitValue (doc.height, doc.height.type);
    pixelWidth.convert ('px');
    pixelHeight.convert ('px');

    // Determine the target aspect ratio and the current aspect ratio of the image.
    var targetAr = arWidth / arHeight;
    var sourceAr = pixelWidth / pixelHeight;

    // Start by setting the current dimensions.
    var resizedWidth = pixelWidth;
    var resizedHeight = pixelHeight;

    // The source image aspect ratio determines which dimension, if any, needs to be changed.
    if (sourceAr < targetAr)
        resizedWidth = (arWidth * pixelHeight) / arHeight;
    else
        resizedHeight = (arHeight * pixelWidth) / arWidth;

    // Apply the change to the image.
    doc.resizeCanvas (resizedWidth, resizedHeight, AnchorPosition.MIDDLECENTER);
}

其他提示

您知道什么语言? ImageMagick具有可以执行此操作的命令行工具,但是您需要了解脚本语言来获取这些值并计算新的语言。

对于.net,我公司的产品, Dotimage照片, ,是免费的,可以做到这一点(需要知道c#或vb.net)

介意 @user268911的接受答案 如果源图像的像素/英寸不同于72。因为 unitvalue.convert 功能仅适用于72 px/英寸。为了确保转换是正确的像素/英寸值,请设置 碱基 属性如下:

 ...
 var pixelWidth = new UnitValue (doc.width, doc.width.type);
 pixelWidth.baseUnit = UnitValue (doc.width.baseUnit, "in");
 var pixelHeight = new UnitValue (doc.height, doc.height.type);
 pixelHeight.baseUnit = UnitValue (doc.height.baseUnit, "in");
 ...

有关转换的更多详细信息,请参见“转换像素和百分比值”部分 Adobe JavaScript工具指南.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top