Author Topic: How do I scale an image  (Read 348 times)

gwandless

  • Newbie
  • *
  • Posts: 1
How do I scale an image
« on: January 14, 2019, 07:13:42 PM »
I have imported a jpg  file and would to scale it. How does one go about doing that?
Thanks,
Greg

Dr PR

  • Hero Member
  • *****
  • Posts: 5653
Re: How do I scale an image
« Reply #1 on: January 14, 2019, 11:59:34 PM »
It all depends upon what you want to do. There are two ways to scale things.

1. Sale the drawing to the image.

Select two places on the image that are a known distance apart - such as marks on a a drawing scale or a ends of a dimension line.

Start the "Dimension/Units" command (U) and set points at the chosen spots. Enter the distance between the points.

Now all parts of the drawing will be created in the scale of the image.

2. Scale the image to the existing drawing.

Select the image.

Start the "Edit/Selection Edit/Scale" command (S). Enter the new X, Y (and Z in 3D mode) scales. Be sure to use the same scale value for each dimension if you do not want to distort the image. Press "Enter"

The image will now be scaled proportional to the existing drawing.

****

CAUTION: Images are imported relative to the pixels in the current screen image, and not to anything in the drawing. I do not know what the ratio of image pixels to screen pixels is.

If you zoom way out and import an image and then zoom way in and import the same image, the first copy will be much larger than the second copy.

If you need to import multiple images all at the same scale, such as several scans of parts of a large drawing, follow these steps:

A. Draw a line on an unused layer. Label this layer "Reference" and then lock it. Never unlock it or draw anything else on the layer.

B. Make the Reference layer visible. Make all other layers invisible. Only the reference line should be visible.

C. Use "View/Fit to Window" to zoom so the reference line fits across the screen.

D. Change to the layer you want to import an image in.

E. Import the image.

F. To import another image at the same pixel density repeat steps B through E.

It is a good idea to keep the reference layer/line until the drawing is finished. This way you can always reestablish the same screen image size relative to the drawing if you need to import another image.

Phil




DesignCAD user since 1987

adriank

  • Hero Member
  • *****
  • Posts: 539
Re: How do I scale an image
« Reply #2 on: January 15, 2019, 05:12:02 AM »
Another handy way to rescale an image - especially if you need to rescale and rotate it to fit your drawing is this:
Import the image at whatever scale it pleases to give you.
Select 2 points on the image that need to align with 2 points of your drawing and use the 'Set Selection Handles' command to place handles on those 2 points.
With the image selected the 2 handles will display - right-click on the first handle and the Select Copy/Move window opens.
Disable the 'Use Original Scale' option.
Left-click (or right click if you don't have a point to snap to) on the 2 points in your drawing you'd like to align your image to.
You can use Edit/Selection Edit/Display Order to get the image to be in front of or behind elements of your drawing unless you have the 'Display Geometry On Top Of Images' option checked in the Options/View menu.

Adrian

bdeck

  • Hero Member
  • *****
  • Posts: 925
Re: How do I scale an image
« Reply #3 on: January 15, 2019, 10:50:08 PM »
Hi Gwandless,

Copy and save the "MS.d3m" macro from here:

http://forum.designcadcommunity.com/index.php?topic=3044.msg16346#msg16346

Be sure it has the "d3m" extension after saving.

Put it in the folder pointed to at DC's menu/options/optoins/filelocations/macros.

To run the macro, select the image, then press SPACE M S ENTER

(You can set up a keyboard shortcut for it, too, but help for that may be slow coming so long as the forum is hobbled)

Best Regards,
bd
« Last Edit: January 15, 2019, 11:45:28 PM by bdeck »

Dr PR

  • Hero Member
  • *****
  • Posts: 5653
Re: How do I scale an image
« Reply #4 on: January 16, 2019, 01:10:14 PM »
bd,

Why would anyone (especially a newbie) want to run the ms.d3m macro? What does it do?

Phil
DesignCAD user since 1987

bdeck

  • Hero Member
  • *****
  • Posts: 925
Re: How do I scale an image
« Reply #5 on: January 16, 2019, 04:46:38 PM »
Why would anyone (especially a newbie) want to run the ms.d3m macro? What does it do?

HI Phil,

Good point.  A better question might be "Why would anyone (especially a newbie) want to use multiple native commands to perform such a simple task?"

However, as slow as the forum is right now, I suppose I might have provided a bit more info...

The ms.d3m macro performs a  move/rotate/scale of any selection in a single operation.

It is particularly useful (and quick) for arranging images of different sizes into an array of uniformly sized images.

If the user runs the macro and sets two points then hits enter, the macro does a point relative move of the selected object, just as if the native move command "M" had been executed with "Use reference point" checked.

If the user runs the macro and then sets four points (plus a fifth random point to confirm point locations) the macro does a point relative move/rotate of the selected entities.

At the end of the command, before completing the move, the macro asks for input on whether to rescale the moved object according to the placement of the 4 points.
   ENTER = no scaling
1 ENTER = scaling

If the user selects scaling, the result is the same as if  the user had used the handle command to first set 2 handles, had then executed the native move command "M", had unchecked "Use original scale" and "Use reference point" options, and then had set two target points.

The link suggested above is to a prior thread in which I modified an existing macro for a user who had a need somewhat similar to that in the present OP. He seemed happy with the result.

For simple unscaled moves,  I use a keyboard shortcut to access the "M.d3m" macro found here:. 

http://forum.designcadcommunity.com/index.php?topic=322.msg1404#msg1404

Consequently, for scaled moves I use a dedicated 4-point-only version of MS.d3m that scales automatically without asking permission.

Heres how that looks:
Code: [Select]
''' MM.d3m  DC6 style Move/Scale macro for 4 point moves  version 0.1 bdeck 2019
'
'
' Select object; run macro.
' Set  2 points for selection starting location, orientation, and scale.
' Set  2 points for selection target location, orientation, and scale.
' Then set a fifth point or hit enter to (or consecutive Esc to edit or exit).
' (This allows you to check your work before committing to the move)
'
'
' Note that sys(36) prevents dialog box cleanup errors.
' Sys(1)=0 does not clean up set points in preset point mode.

If Sys(80) < 1 Then
message "4-Point Move. No entities selected"
End
endif

Sys(41) = 0
dim x(6),y(6), z(6)
n=sys(1)

 
if n> 4 then n=4   ' for preset point mode only **********************
if (n=4) then goto gottem 'use correctly set points

retry:
setpoint "Move/Scale Macro --  Set total of 2 source points,   2 target points,  plus a fifth point or ENTER to confirm" 5
n=sys(1)
if n=0 then goto cleanup
if n<4 then goto retry
if n>4 then n=4

gottem:

sflag=sys(36)
sys(36)=1

for i=1 to n
pointval x(i) y(i) z(i) i
next i
sys(1)=0

if n=4 then

>SetHandle
{
<Pointxyz [x(1), y(1), z(1)]
<Pointxyz [x(2), y(2), z(2)]
}

>Move
{
<Type 0 ' Rotated and scaled
<Pointxyz [x(3), y(3), z(3)]
<Pointxyz [x(4), y(4), z(4)]
}

endif

cleanup:

sys(36)=sflag
sys(1)=0 'clean up unused points
REGEN

This macro requires 2 fewer alpha keys and 2 fewer mouse clicks than the native solution.

BTW: Here are two other macros that may be helpful when images and/or drawn entities overlap  (especially if one has not yet set the 'Display Geometry On Top Of Images' option, as adriank suggested).

Code: [Select]
'''  tt.d3m    macro to move selected entites to top of display order
>MoveToTop
{
  }


Code: [Select]
'''  bb.d3m    macro to move selected entites to bottom of display order
>MoveToBack
{
  }

I wrote the original s/n/m macros in this forum's SDK / User Contributions section some 15 years ago, to make the Win version of DC work as smoothly as my old DOS version.  For my 2d purposes, they appear to still work ok.

Best Regards,

BD
« Last Edit: January 24, 2019, 04:20:15 PM by bdeck »

JJG

  • Hero Member
  • *****
  • Posts: 737
Re: How do I scale an image
« Reply #6 on: January 26, 2019, 02:32:08 AM »
Hi all,

these macros could be usefull too :
http://forum.designcadcommunity.com/index.php?topic=3103.0

 ;)

Lar

  • Hero Member
  • *****
  • Posts: 2828
Re: How do I scale an image
« Reply #7 on: April 17, 2019, 09:30:14 AM »

Start the "Edit/Selection Edit/Scale" command (S). Enter the new X, Y (and Z in 3D mode) scales. Be sure to use the same scale value for each dimension if you do not want to distort the image. Press "Enter"
You can just use the "Selection Zoom" command and enter 1 value when you want to scale things equally in X, Y and Z. It's referred to as "Zoom" in the menu ("Edit/Selection Edit/Zoom").




CAUTION: Images are imported relative to the pixels in the current screen image, and not to anything in the drawing. I do not know what the ratio of image pixels to screen pixels is.
Images are imported 1:1 to the screen resolution. So if you have a 2000 x 1000 screen (just for easy numbers) and you import 1000 x 500 image into dcad, the image will take up one quarter of you screen area (since when you half both sides of a rectangle if fits into one quarter of the original).


Now, once the image is in dcad it is automatically given dimensions relative to how much space it takes up in the dcad drawing. So if you zoom the drawing at all (view-zoom, not scale-zoom), the image will be visually zoomed along with the rest of the drawing. Now, if you then import that very same image again, the 2nd incarnation of the image will again come in based upon the screen resolution. It will come in at the exact same size relative to the screen as it did when you imported the first one (quarter the screen size) but now, since the first image is visually at a different size, this one would take on different width and height values.


If you're importing a series of images and you want them to keep the same size relative to each other, the trick is to not visual-zoom dcad at all until you have imported all of them. Just place them anywhere within the visual area until they are all imported. Then, once all are in, zoom however you need and place them where they need to be. If they need to be resized then select them all and resize them all at once so they remain relative in size. If after visual-zooming you find you need to bring in another image, then un-check "Keep Original Scale" (up top, where you don't notice it) and set 2 points in opposite corners of one of the first images that has the correct size.


How to Prove that Images Come in Relative to the Screen in Dcad:
1] With Dcad running full-screen and with a single full drawing window, press the Print Screen button on the keyboard (with it configured to capture the full screen, if yours can do anything different)….


2] Invoke the "Paste" command…


3] You will see the lower left rubberband corner of the image at the cursor position. I will bet you any money that the rubberband will be too big to fit anywhere in the dcad drawing window, even if by one row or column of pixels (this applies to the modern Windows system, not the MS DOS or any other operating system)…


4] Without zooming at all (if you do, then "Zoom Previous" before you do anything else), or changing the resolution of the computer screen, and with "Keep Original Scale" and "Select Object When Created" checked, click anywhere in a drawing window. The image will appear as per the rubberband preview. It should also be selected and with the Big Blue handle at the bottom-left corner.


5] Now, again without zooming or changing the screen's resolution, gravity snap at the Big Blue handle and move the image to the lowest and most left location you can in the dcad drawing screen.
 
   I can bet you any money that the image will still not fit in the dcad window, but if you compare anything that you can see in the image to anything on the full computer screen, they will be the same size.


The reason I am certain that the image will not fit in any dcad window is because when you pressed the Print Screen key you captured the entire screen image, including dcad's title bar, menu bar, drawing window borders, the Window's taskbar if you have it visible... everything. And since dcad brings images in relative to the screen resolution, the image comes in at the full size of the screen... and since in dcad there is always something bordering the drawing area, ie, the menu (if docked), the status and scroll bars (if on), the title bar (which can't be turned off) and the little tiny 1 pixel vertical borders running down the left and right edges of the screen, which can't be turned off)… the image will not fit entirely in the dcad drawing area. Dcad will have to introduce a "Full Screen Mode" that cuts off everything including the title bar and the 1-pixel vertical borders (like in most imaging apps) and then you be able to move the cursor to the very left-most and bottom-most pixel of your screen... and click there to place the image, and then your screen will look exactly how it looked when you pressed Print Screen.


Now, after importing the image, if you then zoom the screen back so you see clear drawing space around the entire image and then do another Paste command, the rubberband preview of the image-to-be-pasted will once again come in at the full resolution of the computer screen and thus not be able to fit entirely into the dcad drawing area. Upon clicking to place this 2nd image, it will have everything the same as what is on the screen, except the first pasted-in image won't be in the 2nd pasted-in image. The two images will be exactly the same, except the first image will be smaller than the 2nd image.




Lar
« Last Edit: April 17, 2019, 10:11:45 AM by Lar »