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

Canvas Ignore Width and Height #62

Open
khaukheng opened this issue Oct 7, 2018 · 4 comments
Open

Canvas Ignore Width and Height #62

khaukheng opened this issue Oct 7, 2018 · 4 comments

Comments

@khaukheng
Copy link

khaukheng commented Oct 7, 2018

I have set the options as follow

options = {
width: "600", // Width of canvas
height: "500", // Height of canvas
color:"red", // Color for shape and text
type : "rectangle", // default shape: can be "rectangle", "arrow" or "text"
images: ['/assets/images/mockImage.jpg'],
linewidth:2, // Line width for rectangle and arrow shapes
fontsize:"20px", // font size for text
bootstrap: true, // Bootstrap theme design
position: "top", // Position of toolbar (available only with bootstrap)
idAttribute: "id", // Attribute to select image id.
selectEvent: "change", // listened event to select image
unselectTool: false, // display an unselect tool for mobile
onExport: (image)=>{this.export(image)}
};

but the library just ignore my width and height and it will resize based on the image i put and it even goes beyond my screen when my picture is 1920*1080. Any help is much appreciated. Even the demo folder in this github does the same thing.

image

@brad0525
Copy link

any update on this?

@khaukheng
Copy link
Author

any update on this?

No. My current 'hack' is to resize the image with another library first before putting into djaodjin-annotate.

@ChandanCD
Copy link

In Js file modify the if condition inside setBackgroundImage function as following .

if ((self.options.width && self.options.height) !== undefined &&
(self.options.width && self.options.height) !== null) {
self.currentWidth = self.options.width;
self.currentHeight = self.options.height;
self.selectImageSize.width = self.options.width;
self.selectImageSize.height = self.options.height;
} else {
self.currentWidth = this.width;
self.currentHeight = this.height;
}

It worked for me

@khaukheng
Copy link
Author

khaukheng commented Nov 28, 2019

In Js file modify the if condition inside setBackgroundImage function as following .

if ((self.options.width && self.options.height) !== undefined &&
(self.options.width && self.options.height) !== null) {
self.currentWidth = self.options.width;
self.currentHeight = self.options.height;
self.selectImageSize.width = self.options.width;
self.selectImageSize.height = self.options.height;
} else {
self.currentWidth = this.width;
self.currentHeight = this.height;
}

It worked for me

Thanks for your solution, it is working when self.options.width and self.options.height is specified, but cannot annotate if self.options.height or self.options.width is not specified in the options.
This is the corrected version:

if ((self.options.width && self.options.height) !== undefined &&
(self.options.width && self.options.height) !== 0 &&
(self.options.width && self.options.height) !== null) {
self.currentWidth = self.options.width;
self.currentHeight = self.options.height;
self.selectImageSize.width = self.options.width;
self.selectImageSize.height = self.options.height;
} else {
self.currentWidth = this.width;
self.currentHeight = this.height;
self.selectImageSize.width = this.width;
self.selectImageSize.height = this.height;
}

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