Hi,
I have a document that has about 100 copies of a small eps image that I use as a spacer. I've reformatted to a different document size, and now I need to reduce the size of the spacers slightly. Is there any way I can do this without laboriously selecting and changing the size of each one?
I know I can use the 'find image' macro to move to them; but that's not the main part of the work. Especially if I change my mind again later, it would be nice to be able to somehow adjust them all, or at least get part of the work done automatically.
It might help to know that they are in a paragraph with its own style (for the spacer), but I don't see how I can use this to adjust them.
Any hope of this?
Thanks
Steven Rowat
Change size of 100 copies of eps image?
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Change size of 100 copies of eps image?
Hi Steven,
I think you might have some hope here. While it's not technically advertised/supported, macros can actually change the size of images. There are a few quirks, notably that the images won't necessarily redisplay and undo might not work. But I think in your case that should be okay:
Here's a macro that will do what you like:
Just replace the paragraph style name "Spacer" with whatever your document is using. Also, I'd recommend you run this on a copy of your document, because undo may not work as expected. Also, after the macro runs, you'll need to save and reopen the file before the new size is noticed.
I think you might have some hope here. While it's not technically advertised/supported, macros can actually change the size of images. There are a few quirks, notably that the images won't necessarily redisplay and undo might not work. But I think in your case that should be okay:
That will be helpful. What's the name of this paragraph style?stevenrowat wrote:I need to reduce the size of the spacers slightly. Is there any way I can do this without laboriously selecting and changing the size of each one?
...
It might help to know that they are in a paragraph with its own style (for the spacer), but I don't see how I can use this to adjust them.
Here's a macro that will do what you like:
Code: Select all
[Macro code removed. Newer and better version below.]
-
- Posts: 74
- Joined: 2012-02-20 11:48:49
Re: Change size of 100 copies of eps image?
Thanks Martin, and it's certainly fast and I think I'm 90% there, but there's a numerical glitch as follows:martin wrote:Hi Steven,
Just replace the paragraph style name "Spacer" with whatever your document is using. Also, I'd recommend you run this on a copy of your document, because undo may not work as expected. Also, after the macro runs, you'll need to save and reopen the file before the new size is noticed.
Here's what I got, in steps:
[At start, my images are 6.8pt. x 16.5pts; I'm reducing them in size].
a) I put 5.6 pt. x 14 pt in the dialog windows of the macro when prompted.
b) Right away, without quitting, I look at the images: they've changed size and show size correctly in the metrics (ie., 5.6x 14)
c) Quit and re-open to check that this holds.
d) But it doesn't; I Look at images: now they are 4.8x12.35. (The originals were 6.8 x 16.5, so they've changed, but not to what I asked for) .
Don't know why, but perhaps it's because the image proportions are locked in all the image metrics?
So I try changing one image so it's without the lock.
I rerun all above, same result in all steps,
with the unexpected addition that the proportion lock has re-locked on my test image (even though I left it off).
Any ideas?
Steven
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Change size of 100 copies of eps image?
Great, let's see if we can't get the rest working...stevenrowat wrote:Thanks Martin, and it's certainly fast and I think I'm 90% there
I'm not sure, but I bet the problem has something to do with the native size of your images.a) I put 5.6 pt. x 14 pt in the dialog windows of the macro when prompted.
b) Right away, without quitting, I look at the images: they've changed size and show size correctly in the metrics (ie., 5.6x 14)
c) Quit and re-open to check that this holds.
d) But it doesn't; I Look at images: now they are 4.8x12.35. (The originals were 6.8 x 16.5, so they've changed, but not to what I asked for) .
Without getting into all the gory details, basically RTF saves the native size of your image plus a scaling factor. This native size is that originally set forth when the image was produced (eg: when you took a screenshot, etc). So if you add that image into your document, resize it, save the file, and reopen, there could be some kind of rounding error that produces a change in the image size. Nisus Writer emits some custom RTF controls to prevent this problem, but it seems that perhaps it's only effective for some types of images.
Generally I would generally recommend:
1. Using a spacer image whose native size is closer to your target size (eg: 5.6 x 14 pt) so the scaling isn't so extreme, which will avoid the rounding error.
2. Resize the spacer image externally.
3. Use a spacer whose image file format is one where we've corrected this issue (eg: PNG).
I realize your problem began with already having a lot of pre-existing images in your document, so I'm attaching another macro that asks you to choose a new spacer image. The macro then replaces all spacers with the new one.
One final request: could you please send me a snippet of text that includes the problematic spacer? I'd like to make sure we get this fixed for all image types. Thanks.
[Edit: removed attached macro; see newer/improved macros below]
-
- Posts: 74
- Joined: 2012-02-20 11:48:49
Re: Change size of 100 copies of eps image?
Martin, thanks, and I may send it if you still want it later, but first I'm going to throw a curve at you because:martin wrote: I realize your problem began with already having a lot of pre-existing images in your document, so I'm attaching another macro...
One final request: could you please send me a snippet of text that includes the problematic spacer? I'd like to make sure we get this fixed for all image types. Thanks.
a) my attempt to solve it with the first macro almost did the job and I can do the rest by hand, and
b) setting out to change them all again with another macro might lead me to a worse state, and
c) the reason I used the image I did (an eps) was because I wasn't sure of the size it would be used at and it's fully scalable, so I don't really want to limit that, and
d) having to change the style name in the CODE of each macro is an unnecessary burden (I believe you ought to write it so that question pops on the screen: 'What is the Name of the Style', and then the macro will be applicable in future still in other situations (I've already got three different styles with this image in them), and
e) more to the point, I think there's a better way that I'm going to try to interest you in for a future Nisus release: glyphs.
This is a big feature but I think it's worth it.
Consider:
A) A given spacer image is only being used as an image because it isn't at this moment available as a glyph (a letter). But, ideally, it's functioning exactly as a glyph and would follow all the rules of typography perfectly -- sizing, centering, etc. -- if it was a glyph; including replacement, search, etc.
B) I decided this two years ago and spent several days fussing with typography (TypeTool, etc.) in both Linux and Apple to construct a glyph of this exact spacer, and made a true type font with it, and installed it. This was far too hard at that time but I think it's easier to do now. It should have been just drag and drop. And it turned out I need to edit it slightly and because the whole train of events was annoyingly long, I went back to using the image (which I'm still using now).
C) Here's the suggestion: I think a whole world would open up for your users if getting a scalable vector graphic or eps graphic into use as a glyph was made easy to do in Nisus: and I think you probably have the tools to do this with, behind the scenes, in an elegant way.
D) If you do this then the use of images for typographic functions will cease to be a problem; it will disappear. You can just direct people to drop their image into the little glyph factory (which you set up as part of Nisus) and presto, their image is a letter, scalable, searchable, moveable, etc.
Steven Rowat
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Change size of 100 copies of eps image?
That's easy enough to change. I'm attaching new macros here, in case they're useful for you.stevenrowat wrote:d) having to change the style name in the CODE of each macro is an unnecessary burden (I believe you ought to write it so that question pops on the screen: 'What is the Name of the Style', and then the macro will be applicable in future still in other situations (I've already got three different styles with this image in them), and
Thanks for the idea, but there are some problems with this, and it seems somewhat outside the scope of NWP.e) more to the point, I think there's a better way that I'm going to try to interest you in for a future Nisus release: glyphs.
As you probably know, a glyph is essentially just a vector graphic that comes from a font. So NWP could let you create a font. Probably we could make the process of getting a vector graphic into a font easier than whatever tools you were using, but this seems a strange fit for a word processor. And creating a font just for a single graphic isn't a great situation to begin with. You'd still be stuck sharing/installing this font whenever you needed to transfer your document between computers, choosing and co-opting an existing character code for your glyph, etc.
I'd say it makes more sense to solve this using a different approach. Some ideas:
1. Ability to insert a single image multiple times, where all inserted copies always reference the original. This is actually already possible using the "link to file" option, if you're willing to have the image be stored external to your document.
2. Cross-references should be able to display a bookmarked image. I'm actually a little surprised that we don't already allow for this; I'll see about filing an enhancement request.
3. Some kind of style that always enforces a particular image/size.
[Edit: attached macros deleted; please see newer/enhanced macros below]
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Change size of 100 copies of eps image?
Oh, one tip I forgot to mention: if you paste an image into the Find panel, it will match all other images (any kind, any size). However, if you turn on the "attribute sensitive" option, only images with exactly the same size will be matched.
Having a copy of this image (or better yet, document snippet) would still be helpful, thank you. I expect we'll have this loss of precision bug fixed for all image types regardless, but we always prefer to have the exact same materials as the user, just to make sure. Thank you.Martin, thanks, and I may send it if you still want it later
-
- Posts: 74
- Joined: 2012-02-20 11:48:49
Re: Change size of 100 copies of eps image?
Thanks, I approached these with some trepidation; which was unfounded.martin wrote: That's easy enough to change. I'm attaching new macros here, in case they're useful for you.
Both the resize and the replace Macros you provided above work as you suggest, and having the style name available means I can re-use this in the GUI easily. An unexpected plus was that in one style I have multiple copies of the image on one line (ie, in a single paragraph in the same style), but both macros handled these transparently.
The only things I'll note are that in one case all links to all images in my document appeared broken (using the replace Macro), but after quitting Nisus and reopening, all the old and changed images appeared as expected. In another case the replace didn't subvert anything and displayed immediately without needing to quit.
Second, the rounding error is still there; it would be required to have this fixed for fine changes and I'm hopeful that you'll figure that out; but I can work with these macros for some situations, where the needed change is large and hence the rounding error is acceptable.
Thank you.
Steven
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Change size of 100 copies of eps image?
Excellent, glad to hear it. One final improvement: the macro can just list all available styles instead of making you type a name by hand. I'm attaching the final macros here.stevenrowat wrote:Both the resize and the replace Macros you provided above work as you suggest, and having the style name available means I can re-use this in the GUI easily. An unexpected plus was that in one style I have multiple copies of the image on one line (ie, in a single paragraph in the same style), but both macros handled these transparently.
When you say links, do you mean cross-references that were targeting those images? Well, that might be expected if the bookmark only encompasses the image, since the macro does a full replace, which basically deletes the old content before inserting the new content.The only things I'll note are that in one case all links to all images in my document appeared broken (using the replace Macro), but after quitting Nisus and reopening, all the old and changed images appeared as expected.
Yes, the rounding error will persist so long as you use an image format that requires RTF's "object" control (eg: EPS and other modern vector formats), and your desired/resized image dimensions are significantly different than the image's native size.Second, the rounding error is still there; it would be required to have this fixed for fine changes and I'm hopeful that you'll figure that out
If you switch to one of the native RTF image formats (eg: PNG, JPEG, or PICT) Nisus Writer emits special controls to prevent the issue. We'll workaround RTF's limitation for EPS and other "object" images, but you'll have to live with it for now. Thank you for sending your image along privately to ensure we get this fixed.
- Attachments
-
Image Resize All.nwm
- (24.29 KiB) Downloaded 472 times
-
Image Replace All.nwm
- (24.3 KiB) Downloaded 458 times
-
- Posts: 74
- Joined: 2012-02-20 11:48:49
Re: Change size of 100 copies of eps image?
No, I was inexact. I meant that the little cross-box appears instead of the image; indicating I assumed that the link to the file is somehow compromised; but it could be some other reason.martin wrote:When you say links, do you mean cross-references that were targeting those images?
And thank you for the new versions with style choice list; this is very nice. I tried the size change one and it worked well. And I also changed the images to a larger size (for test) and the difference from my target, after re-opening, was minimal; evidence I think that what you said is true; rounding is more of a problem the further from the original size.
Thanks again for the macros. I believe I will use them in this project and having them will make me more more confident about adding spacer images in other projects. It's especially nice to be able to add the same spacers at first but with different styles for different position contexts, and then adjust or replace them separately, per style, with the macros.