Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dxf Image dimensions issue #36

Open
Magorick opened this issue Nov 11, 2022 · 2 comments
Open

Dxf Image dimensions issue #36

Magorick opened this issue Nov 11, 2022 · 2 comments

Comments

@Magorick
Copy link

Magorick commented Nov 11, 2022

Hi,

I am trying to add images to dxf with different dimensions, setting different width and height.
I found out that if I set smaller values to width and height, the images get bigger.

code example:

const dxf = new DxfWriter();

//IMAGE 1
const img1 = dxf.addImage(
'C:\Users\dev\Desktop\example.jpg', //Or the absolute path if not in the same folder.
'TEST', //The name of the image.
point3d(10, 10, 0), // The insertion point.
600, // The width of the image in pixels.
600, //The height of the image in pixels.
1, //The scale to be applied to the image.
0 //The rotation angle (Degrees) to be applied to the image.
);
img1.clippingStateFlag = 0;

//IMAGE 2
const img2 = dxf.addImage(
'C:\Users\dev\Desktop\example.jpg', //Or the absolute path if not in the same folder.
'TEST', //The name of the image.
point3d(-10, -10, 0), // The insertion point.
60, // The width of the image in pixels.
60, //The height of the image in pixels.
1, //The scale to be applied to the image.
0 //The rotation angle (Degrees) to be applied to the image.
);
img2.clippingStateFlag = 0;

const dxfString = dxf.stringify();
this.downloadFile(dxfString);


In the output dxf file, "IMAGE 2" (width 60 , height 60) is TEN times bigger than "IMAGE 1" (width 600 , height 600) and
I was expecting the opposite result.

image

Maybe am I missing something?

@Magorick Magorick changed the title Dxf Image dimension issue Dxf Image dimensions issue Nov 11, 2022
@tarikjabiri
Copy link
Member

Hi,

Really I have no idea why this work like that, but the width and height should be the acual width and height of the image in pixels, and you can control the size by the scale property.

But I will investigate when I have some time.

Regards

@divya-shiv-pandey
Copy link

divya-shiv-pandey commented Nov 23, 2022

You can do a custom scaling for the Image like shown below. It only works for square Images...
this.dxf.addImage(
Image Path Here, // Or the absolute path of the image if it isn't in the same folder.
Random Name,
point, // Insertion point of the bottomLeft corner of the image.
width, // the width of the image
height, // the height of the image
(width * width) / 1024, // Scale
0, // rotation
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants