Managing linked images

Everything related to our flagship word processor.
Post Reply
ptram
Posts: 280
Joined: 2007-10-21 14:59:09

Managing linked images

Post by ptram »

Hi,

I'm working on a document with a lot of linked images. There are some things I cannot fully understand.

- To see the file path, I can just hover over the image. Is there a way to generate a list of all the paths of all linked images? (Maybe I could parse the RTF file with a text editor, and search for all the images).

- Is there a way of knowing if an image is included or linked?

- Is there a way to relink an image that is included or linked to the wrong path? (I guess the second operation can be done on the RTF file with a text editor).

- When copying and pasting a linked image, a red frame appears around the pasted image. What does it mean? Is there a way to reset its appearence? Is the pasted image still linked, or embedded?

Thank you!
Paolo
User avatar
Hamid
Posts: 777
Joined: 2007-01-17 03:25:42

Re: Managing linked images

Post by Hamid »

ptram wrote:[...]- To see the file path, I can just hover over the image. Is there a way to generate a list of all the paths of all linked images?[...]
You may try one of Kino's macros on a test file:
MakeLinkIndex which makes an index of links with page numbers or MakeLinkVisible which inserts link destination text after each link with $prefix and $suffix:
http://www2.odn.ne.jp/alt-quinon/files/NWPro/link/
ptram
Posts: 280
Joined: 2007-10-21 14:59:09

Re: Managing linked images

Post by ptram »

Hamid,

Thank you very much for having let me discover such great collection of macros.

However, the type of 'link' I was referring to was no to URLs, but to image files. When you insert an image into a Nisus document, you can choose not to include it in the document, but only place a link to the external file. This will make the document lighter, while showing any edit you could do to the linked file with an external editor.

Sometimes, it is useful to know if your linked images come from the right folder or from the image folder of a different document, from which you might have copied text and images. Having the documents linked to the correct external files is very important, to avoid editing the wrong image file or missing images when moving the Nisus document and the external image folder.

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

Re: Managing linked images

Post by phspaelti »

When I saw this discussion I was going to whip up a quick macro to do this. That's when I (re)discovered that the Nisus Macro language currently does not have any way to get the file path of an image (linked or embedded) :!: There is also no way (with the macro language) to find out whether a given image is embedded or linked.
There is a command "Encode as RTF" which could be used to work around this problem. I did a quick test and using the command on a selected image would provide a way to retrieve the necessary info, I believe. So one could write a loop to do a quick test on each image in the file. Here's an example of how that would work.

Code: Select all

$doc = Document.active
$imgInfo = Hash.new
foreach $img in $doc.allImages
	$imgText = $img.anchorText.subtextInRange $img.anchorTextRange
	$rtf = Encode RTF $imgText
	$rtf = Cast to String $rtf
	$find = $rtf.find 'Link to Image'
	if $find
		$imgInfo{$img} = 'linked'
	else
		$imgInfo{$img} = 'embedded'
	end
end
Debug.log $imgInfo
One would have to know a bit more than I do about RTF encoding to be sure this works right.
philip
ptram
Posts: 280
Joined: 2007-10-21 14:59:09

Re: Managing linked images

Post by ptram »

Thank you very much, Philip, for you programming hints! Now, if the nice guys at Nisus want to add the missing parameters... :)

Another thing that I would find very useful is a macro replacing strings in a particular format with linked images. There is a similar macro for InDesign, and it is very handy when having to replace all images from a document you received from translators not working with the same application. I fear it would be very useful when sending Nisus documents to a translator using Word or LibreOffice.

The macro would find all strings of the type

@[image.tif]@

and replace it with a linked image with the same name, found in a folder you specify when running the macro. I don't think something similar exists for Nisus Writer, but I guess it would be useful for anyone wanting to work on images only after having edited the text (either in Nisus Writer, or in some obscure markdown editor on the iPad...)

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

Re: Managing linked images

Post by phspaelti »

ptram wrote:Another thing that I would find very useful is a macro replacing strings in a particular format with linked images. There is a similar macro for InDesign, and it is very handy when having to replace all images from a document you received from translators not working with the same application. I fear it would be very useful when sending Nisus documents to a translator using Word or LibreOffice.

The macro would find all strings of the type

@[image.tif]@

and replace it with a linked image with the same name, found in a folder you specify when running the macro. I don't think something similar exists for Nisus Writer, but I guess it would be useful for anyone wanting to work on images only after having edited the text (either in Nisus Writer, or in some obscure markdown editor on the iPad...)
Voila:
Macro Insert Images from Tags.nwm
(5.2 KiB) Downloaded 434 times
philip
ptram
Posts: 280
Joined: 2007-10-21 14:59:09

Re: Managing linked images

Post by ptram »

Philip,

THANK YOU VERY MUCH! You didn't even get the pleasure of making me wait and suffer a little, before sending it!

Judging from the size of the resulting file, I guess images are embedded into the document. I'm looking through the macro manual to see if there is a way to add an option to avoid including a copy of the linked file into the document.

Best,
Paolo
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Managing linked images

Post by phspaelti »

Yes, it seems that the images are always inserted embedded. And it doesn't look like the macro language has any way to control for that. (The macro language allows insertion of alias-links to files, but this is unlikely to result in the insertion of a linked image, even if the file is an image file.
So there seems to be some room for improvement in the Nisus Macro language. :P
philip
ptram
Posts: 280
Joined: 2007-10-21 14:59:09

Re: Managing linked images

Post by ptram »

Philip, I'm not a software engineer, but by reading the macro language reference I cannot find anything useful for what I'm looking for. Let's hope for the next release.

Paolo
Post Reply