Change embedded TIFFs to JPEGs in rtf document

Everything related to our flagship word processor.
Post Reply
alanterra
Posts: 9
Joined: 2013-10-08 13:58:39

Change embedded TIFFs to JPEGs in rtf document

Post by alanterra » 2016-11-23 17:05:17

Hi

I have a document that is growing in size quickly. It has hundreds of screen grabs in it, and they all seem to have come in (through screenshot to clipboard, paste into document) as TIFFs.

Is there any easy way to convert these TIFFs to JPGs? It is not worth the time to go through the document, paste into, say Photoshop, save as JPG, and then import into the document, but if there was an easy way to do this, it would be so cool.

I know how to change the size of a pdf using various tools, but I don't know of any similar tools for rtf documents.

Thanks

User avatar
phspaelti
Posts: 889
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Change embedded TIFFs to JPEGs in rtf document

Post by phspaelti » 2016-11-23 19:50:49

Assuming Photoshop has a batch processing feature, you could do this as follows:
  1. Extract the images from the document (see this discussion https://www.nisus.com/forum/viewtopic.php?f=18&t=6473)
  2. Convert the images using the batch feature
  3. Use a macro to replace the images with the converted ones
If you are already keeping your images in a folder (in some more or less systematic fashion), the first step is already done.
philip

alanterra
Posts: 9
Joined: 2013-10-08 13:58:39

Re: Change embedded TIFFs to JPEGs in rtf document

Post by alanterra » 2016-11-23 20:18:36

Thanks, Phillip. I'll look into this. I haven't scripted Nisus Writer before. And, yes, Photoshop can be scripted -- there are lots of limitations, but it can be made to work.

User avatar
phspaelti
Posts: 889
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Change embedded TIFFs to JPEGs in rtf document

Post by phspaelti » 2016-11-23 21:09:15

I don't know Photoshop. I use Graphic Converter. And it allows batch conversion as a simple operation (no scripting needed).

As for Nisus, a macro to replace inline images of one type with images with the same names, and an extension '.jpg' would look something like this:

Code: Select all

$jpegFolderPath = Choose Folder # ... or specify 
$doc = Document.active
foreach $img in $doc.allImages
$jpegName = $img.name.filePathByChangingExtension 'jpg'
    $jpeg = Image.newFromFileAtPath $jpegFolderPath.filePathByAppendingComponent($jpegName)
    $text = $img.anchorText
    $loc = $img.anchorTextRange.location
    $text.deleteInRange $img.anchorTextRange
    $text.insertAtIndex $loc, $jpeg
end
philip

Vanceone
Posts: 105
Joined: 2013-05-03 07:06:31

Re: Change embedded TIFFs to JPEGs in rtf document

Post by Vanceone » 2016-12-05 14:15:42

You do not need to use Photoshop; the built-in "Automator" program can batch convert an entire set of files.

What I would do is save your Nisus document as file type "RTFD". This will generate a file that actually has all of your images inside a folder inside the file. You can then batch process all of those images, and use the macro provided.

If you haven't used Automator before, it is pretty easy, especially if you know how to script photoshop already. But no need for Photoshop at all.

Post Reply