Convert RGBA color to RGB

I’ve upvoted Johannes’ answer because he’s right about that. * A few comments have been raised that my original answer was not correct. It worked if alpha values were inverted from the normal. By definition, however, this won’t work in most cases. I’ve therefore updated the formula below to be correct for the normal case. … Read more

Automatic contrast and brightness adjustment of a color photo of a sheet of paper with OpenCV

Contrast and brightness can be adjusted using alpha (α) and beta (β), respectively. These variables are often called the gain and bias parameters. The expression can be written as OpenCV already implements this as cv2.convertScaleAbs() so we can just use this function with user defined alpha and beta values. import cv2 image = cv2.imread(‘1.jpg’) alpha … Read more

Browser/HTML Force download of image from src=”data:image/jpeg;base64…”

Simply replace image/jpeg with application/octet-stream. The client would not recognise the URL as an inline-able resource, and prompt a download dialog. A simple JavaScript solution would be: //var img = reference to image var url = img.src.replace(/^data:image\/[^;]+/, ‘data:application/octet-stream’); window.open(url); // Or perhaps: location.href = url; // Or even setting the location of an <iframe> element, … Read more

Is it possible to display inline images from html in an Android TextView?

If you have a look at the documentation for Html.fromHtml(text) you’ll see it says: Any <img> tags in the HTML will display as a generic replacement image which your program can then go through and replace with real images. If you don’t want to do this replacement yourself you can use the other Html.fromHtml() method … Read more

Make an image responsive – the simplest way [duplicate]

You can try doing <p> <a href=”https://stackoverflow.com/questions/15458650/MY WEBSITE LINK” target=”_blank”> <img src=”https://stackoverflow.com/questions/15458650/IMAGE LINK” style=”width:100%;” border=”0″ alt=”Null”> </a> </p> This should scale your image if in a fluid layout. For responsive (meaning your layout reacts to the size of the window) you can add a class to the image and use @media queries in CSS to … Read more

How to use “Share image using” sharing Intent to share images in android?

Bitmap icon = mBitmap; Intent share = new Intent(Intent.ACTION_SEND); share.setType(“image/jpeg”); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes); File f = new File(Environment.getExternalStorageDirectory() + File.separator + “temporary_file.jpg”); try { f.createNewFile(); FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); } catch (IOException e) { e.printStackTrace(); } share.putExtra(Intent.EXTRA_STREAM, Uri.parse(“file:///sdcard/temporary_file.jpg”)); startActivity(Intent.createChooser(share, “Share Image”));

What is the best image downscaling algorithm (quality-wise)?

Unfortunately, I cannot find a link to the original survey, but as Hollywood cinematographers moved from film to digital images, this question came up a lot, so someone (maybe SMPTE, maybe the ASC) gathered a bunch of professional cinematographers and showed them footage that had been rescaled using a bunch of different algorithms. The results … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)