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

Ability to set background color when "over cropping" to enlarge canvas #467

Closed
jywarren opened this issue Nov 12, 2018 · 6 comments
Closed

Comments

@jywarren
Copy link
Member

When the crop module is given dimensions larger than the original image, it adds blank (transparent) pixels to the image edges; see this example:

http://sequencer.publiclab.org/examples/#steps=crop{x:0|y:0|w:611|h:479}

image

It would be excellent to offer as a parameter the color that can be filled instead of left blank. Here is the section of code where it's performed; perhaps we could tell if a pixel is outsider the original bounds and fill it with the given color?

var ox = options.x;
var oy = options.y;
var w = options.w;
var h = options.h;
var iw = pixels.shape[0]; //Width of Original Image
var newarray = new Uint8Array(4*w*h);
for (var n = oy; n < oy + h; n++) {
newarray.set(pixels.data.slice(n*4*iw + ox, n*4*iw + ox + 4*w),4*w*(n-oy));
}
pixels.data = newarray;

@gitmate
Copy link

gitmate bot commented Nov 12, 2018

GitMate.io thinks possibly related issues are #5 (image cropping module), #229 (follow-up refinements to crop image selection UI), and #352 (Patch on delete a sequence after crop).

1 similar comment
@gitmate
Copy link

gitmate bot commented Nov 12, 2018

GitMate.io thinks possibly related issues are #5 (image cropping module), #229 (follow-up refinements to crop image selection UI), and #352 (Patch on delete a sequence after crop).

@JKusio
Copy link

JKusio commented Nov 12, 2018

It looks interesting! But how would we set the color? RGB, HEX, or color input?

Anyway, I'd like to work on that one 😅

@jywarren
Copy link
Member Author

jywarren commented Nov 13, 2018 via email

@Mridul97
Copy link

@jywarren I would love to work on this!

@jywarren
Copy link
Member Author

jywarren commented Dec 26, 2018 via email

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

No branches or pull requests

3 participants