Reply to topic  [ 5 posts ] 
Macro to set uniform size of all graphics in table 
Author Message

Joined: 2011-01-12 05:32:38
Posts: 256
I'm wondering is someone could help me out. I have a table of alphabet characters that are handwritten images. Each image is 200x200 pixels. However, although the pixel size needs to stay at 200, all the images need to be resized down within NWP 2.0.7 so they are uniform and don't take up quite so much space (they have expanded the table cells).

I'd like a macro that somehow would let me tell NWP how much to shrink down their visual image (not the files themselves). And it'd also be nice if there were a macro that would change column height only. I have a macro from 2012 that Philip wrote to adjust table column width, but I can't find one for height.

I don't have the skills to write these, but I'd sure appreciate some help.


2014-04-09 05:14:56
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
The way images work in Nisus is that you can resize them, but this won't affect their 'real' size, i,e,, the source size stays the same and can always be restored. I take it you are putting your images into table cells, and what I find is that the first time you do it Nisus does a good job of giving them sizes that fit, but when you try to add more later, other constraints come into play and it's hard to get them the size you want.
I think though the best approach is not to manipulate the table cell size, but rather to try to set the image size to what you want. Here is some code that will do this kind of thing:
Code:
$doc = Document.active
$imgs = $doc.selection.enclosedInlineImages
if ! $imgs
exit 'No images selected'
end

$h = 200
foreach $img in $imgs
    $proportion = $img.sourceWidth / $img.sourceHeight
    $img.width = $h * $proportion
    $img.height = $h
end


If you run this code it should give all the selected images the same height 200 (points?) while keeping the image proportions. Now I say "should". When I tried it earlier Nisus was giving me funny results. If I ran the macro in draft view, it would only show the new size in page view and vice versa. Don't know what's going on :? But I think if you save the file and then reopen it, things should probably be fine. (Make back-up copies, obviously.)

_________________
philip


2014-04-09 05:52:36
Profile

Joined: 2011-01-12 05:32:38
Posts: 256
Based on the weirdness of the way NWP handles this, I wonder if it'll be necessary to somehow have the macro make a new table and then paste the contents (copied from the old table) so NWP's memory of the "original size" is uniform.

And then it may be necessary to have a new document made after the macro is applied (or have it close and re-open) since the changes don't always seem to "take".


2014-04-09 10:46:11
Profile

Joined: 2011-01-12 05:32:38
Posts: 256
I found that one column in my table was a different width (I found out by using Philip's macro to change column width in tables). Seems NWP automatically adjusts the size of graphics inserted within tables to the width of the table, since when I changed the column width, the graphics in that column all automatically shrunk to the size of the other graphics. My problem is that I don't want the graphics to fill the entire width of the table cells. I haven't found an automatic way to fix that.


2014-04-09 23:33:55
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
NisusUser wrote:
My problem is that I don't want the graphics to fill the entire width of the table cells. I haven't found an automatic way to fix that.

For this you need to either make sure that the images are narrower than the width of the cell, or use cell padding.

_________________
philip


2014-04-10 02:02:36
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software