Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Colouring a greyscale tiff by find/replace or a script?

Contributor ,
Oct 05, 2017 Oct 05, 2017

Hi,

Is anyone aware of a way to batch colourise placed tiffs?

By that I mean when you place a greyscale tiff, double-click or use direct selection tool, go to Swatches, and pick the colour you want. Effectively creating a monotone image instead of using Photoshop.

I want to do that to over 300 images in the same document without using Photoshop for that.

Object styles won't do it.

Find/change won't do it.

Is there a trick, script or workaround to batch it?

Ta

715
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 05, 2017 Oct 05, 2017

set s to "PANTONE 286 C"

set theLayer to "Layer 1"

tell application "Adobe InDesign CC 2017"

    tell active document

        set im to all graphics

        set c to item 1 of (every swatch whose name is s)

        repeat with x in im

            try

                if class of x is image and space of x is "Grayscale" and item layer of x is layer theLayer then

                    set fill color of x to c

                end if

            end try

        end repeat

    end tell

end tell

Translate
Community Expert ,
Oct 05, 2017 Oct 05, 2017

It sounds as though an image could be made various colors. If so, how would a script know what specific color to make an image? Or, would you want a random color applied?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 05, 2017 Oct 05, 2017

It picks a particular swatch to use, e.g. "Pantone 286 C"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 05, 2017 Oct 05, 2017

I found a script that I think would do what I'm after but I can't even get it to compile to try out.

tell application "Adobe InDesign CC 2017"

tell document 1

try

set theImages to all graphics of layer “Layer 1”

repeat with thisImage in theImages

set the properties of thisImage to {fill color:swatch “Pantone 286 C”}

end repeat

end try

end tell

end tell

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2017 Oct 05, 2017

Try this:

set s to "PANTONE 286 C"

tell application "Adobe InDesign CC 2017"

    set im to all graphics of active document

    set c to item 1 of (every swatch of active document whose name is s)

    repeat with x in im

        try

            if class of x is image and space of x is "Grayscale" then

                set fill color of x to c

            end if

        end try

    end repeat

end tell

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 05, 2017 Oct 05, 2017

WOW!

I couldn't get it to work until I realised "Grayscale" needed to be "Greyscale" (I'm in the UK).

That's awesome. That really helps. Many thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2017 Oct 05, 2017

Did you then also need 'set fill colour of ..."?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 05, 2017 Oct 05, 2017

Rob,

There's one issue with the script and that's it will pick up any greyscale image and colour it.

I've done a quick test and there's another image in the document that gets coloured.

Is there a way to adapt the script so it choose a specific layer first, e.g. "Layer 1"? Then it will only colour greyscale images on that layer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2017 Oct 05, 2017

set s to "PANTONE 286 C"

set theLayer to "Layer 1"

tell application "Adobe InDesign CC 2017"

    tell active document

        set im to all graphics

        set c to item 1 of (every swatch whose name is s)

        repeat with x in im

            try

                if class of x is image and space of x is "Grayscale" and item layer of x is layer theLayer then

                    set fill color of x to c

                end if

            end try

        end repeat

    end tell

end tell

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 05, 2017 Oct 05, 2017
LATEST

Again, thank you so much. That now adds a bit of security rather than blanket changing greyscale tiffs.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines