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

Manipulate buffer on the pixel level but let the rest of the image untouched #1452

Closed
akidee opened this Issue Nov 8, 2018 · 2 comments

Comments

2 participants
@akidee

akidee commented Nov 8, 2018

My uncompressed input TIFF has 3 channels a 16 bits and important metadata and profile. I want to access and change some pixels by their raw values and then save the resulting image in the same format, size and with the same metadata:

img.metadata().then(data => {
	console.log(data)
	// Get metadata to known how to access single pixels ...
	img.toBuffer().then(buffer => {
		// Manipulate buffer ...
		img.clone() // Clone metadata, too - sharp(Buffer) would just set the raw buffer
		.overlayWith(buffer) // What is the best way to just re-set the buffer? What about joinChannel()?
		.toFile(newFileName).then(
			info => { console.log(info) },
			e => { console.error(e) }
		)
	}, e => { console.error(e) })
}, e => { console.error(e) })

Result: The image is saved as 8 bit TIFF with JPEG compression, and the metadata is missing.

@lovell

This comment has been minimized.

Owner

lovell commented Nov 10, 2018

Hello again, withMetadata provides control over output image metadata, tiff provides control over TIFF output options and your question at #1454 covers the bit depth.

@lovell lovell added the question label Nov 10, 2018

@lovell

This comment has been minimized.

Owner

lovell commented Dec 4, 2018

Hope this helped, please feel free to re-open with more information if further help is required.

@lovell lovell closed this Dec 4, 2018

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