JPEG image with alpha channel on website

JPEG image with alpha channel on website

Content Index :

JPEG image with alpha channel on website
Tag : development , By : Tim Coffman
Date : January 10 2021, 01:57 PM

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Convert alpha channel in white when saving to JPEG with ImageWriter

Tag : java , By : DotNetWise
Date : March 29 2020, 07:55 AM
this one helps. I'm converting a png image to jpeg with the following snippet of code: , My solution is ugly and probably slow, but it's a solution :)
    BufferedImage img = <your image>
    for( int i = 0; i < img.getWidth( ); i++ )
        for( int j = 0; j < img.getHeight( ); j++ ) {
            // get argb from pixel
            int coli = img.getRGB( i, j );
            int a = coli >> 24 & 0xFF;
            int r = coli >> 16 & 0xFF;
            int g = coli >> 8 & 0xFF;
            int b = coli & 0xFF;
            coli &= ~0xFFFFFFFF;
            // do what you want with a, r, g and b, in your case :
            a = 0xFF;
            // save argb
            coli |= a << 24;
            coli |= r << 16;
            coli |= g << 8;
            coli |= b << 0;
            img.setRGB( i, j, coli );

OpenCV 2.4 Jpeg to PNG with alpha channel

Tag : cpp , By : ZsA
Date : March 29 2020, 07:55 AM
To fix this issue I have a JPEG and a Mask. I want to create a PNG with the three JPEG channels and the alpha channel should be the Mask. How can I achieve this with OpenCV? , for your answer, I found a second solution:
cv::Mat transparent( height, width, CV_8UC4);
cv::Mat srcImg[] = {JPEG_img, alpha_Mask};
int from_to[] = { 0,0, 1,1, 2,2, 3,3 };
cv::mixChannels( srcImg, 2, &transparent, 1, from_to, 4 );

how to add an alpha channel of particular value in an BGR image

Tag : python , By : Dmitry
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Your code is actually correct.
The simple answer is that OpenCV's imshow() ignores transparency, so if you want to see its effect, save your image as a PNG/TIFF (both of which support transparency) and view it with a different viewer - such as GIMP, Photoshop or feh.
#!/usr/bin/env python3

import cv2
import numpy as np

def imshow(title,im):
    """Decorator for OpenCV "imshow()" to handle images with transparency"""

    # Check we got np.uint8, 2-channel (grey + alpha) or 4-channel RGBA image
    if (im.dtype == np.uint8) and (len(im.shape)==3) and (im.shape[2] in set([2,4])):

       # Pick up the alpha channel and delete from original
       alpha = im[...,-1]/255.0
       im = np.delete(im, -1, -1)

       # Promote greyscale image to RGB to make coding simpler
       if len(im.shape) == 2:
          im = np.stack((im,im,im))

       h, w, _ = im.shape

       # Make a checkerboard background image same size, dark squares are grey(102), light squares are grey(152)
       f = lambda i, j: 102 + 50*((i+j)%2)
       bg = np.fromfunction(np.vectorize(f), (16,16)).astype(np.uint8)

       # Resize to square same length as longer side (so squares stay square), then trim
       if h>w:
          longer = h
          longer = w
       bg = cv2.resize(bg, (longer,longer), interpolation=cv2.INTER_NEAREST)
       # Trim to correct size
       bg = bg[:h,:w]

       # Blend, using result = alpha*overlay + (1-alpha)*background
       im = (alpha[...,None] * im + (1.0-alpha[...,None])*bg[...,None]).astype(np.uint8)


if __name__ == "__main__":

    # Open RGBA image
    im = cv2.imread('paddington.png',cv2.IMREAD_UNCHANGED)

    imshow("Paddington (RGBA)",im)
    key = cv2.waitKey(0)

    # Open Grey + alpha  image
    im = cv2.imread('paddington-ga.png',cv2.IMREAD_UNCHANGED)

    imshow("Paddington (grey + alpha)",im)
    key = cv2.waitKey(0)

How to save an image as Tiff or PNG with an alpha channel or alpha mask in iPhone SDK?

Tag : iphone , By : Bin
Date : March 29 2020, 07:55 AM

Canvas with PNG + alpha channel to JPEG dataUrl

Tag : html , By : Milander
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Lucene exact ordering
  • How should I monitor potential threats to my site?
  • Generating Icon Files
  • Suggestions for Adding Plugin Capability?
  • IE8 overflow:auto with max-height
  • Zip library options for the Compact Framework?
  • What is Turing Complete?
  • Creating rounded corners using CSS
  • What is the best way to draw skinnable "buttons" in a video game?
  • Beginning Shader Development
  • Developing addins for World of Warcraft - Getting started?
  • Preferred way to use favicons?
  • Which Agile software development methods have you had the most success with?
  • What client(s) should be targeted in implementing an ICalendar export for events?
  • Gathering OS and tool version numbers for build archive purposes
  • Log4Net configuring log level
  • API Yahoo India Maps
  • Are there any negative reasons to use an N-Tier solution?
  • mailto link for large bodies
  • Is it just me, or are characters being rendered incorrectly more lately?
  • How do I create an HTML anchor in a FogBugz wiki page?
  • Sleep from within an Informix SPL procedure
  • License Models
  • Rational Purify failing to jump to memory leaks
  • Telligent's Community Server
  • Do people use the Hungarian Naming Conventions in the real world?
  • Memcached chunk limit
  • How do you pull the URL for an ASP.NET web reference from a configuration file in Visual Studio 2008?
  • How to add CVS directories recursively
  • Web App Beta
  • Virtual machine supporting multiple displays
  • LINQ to SQL strings to enums
  • How do I configure eclipse (zend studio 6) to hint and code complete several languages?
  • Recommended Fonts for Programming?
  • Automating VMWare or VirtualPC
  • How do I use more than one OpenID?
  • Domain Specific Language resources
  • Vista or XP for Dev Machine
  • Where can I get the Windows Workflow "wca.exe" application?
  • How to learn ADO.NET
  • What is a good barebones CMS or framework?
  • What's the Developer Express equivalent of System.Windows.Forms.LinkButton?
  • Is it acceptable for invalid XHTML?
  • Anyone soloing using fogbugz?
  • Using MBUnit in TeamCity
  • How to setup a crontab to execute at specific time
  • Linking two Office documents
  • How can I detect if a browser is blocking a popup?
  • Apply filter to t-foreach
  • Lotus Notes convert formula to agent
  • Problem with configuration of odoo for working with pycharm
  • Unexpected number of arguments when calling EM_JS function
  • What does the function state_fidelity() do in Qiskit?
  • Azure function with IoT Hub trigger get send device
  • Cluster similar words using word2vec
  • Add elements into an array then find distinct,
  • Angular8 - error TS2304: Cannot find name
  • Manually polling streams in future implementation
  • How do you perform receipt validation for Android on Xamarin Forms
  • What is the rule behind instruction count in Intel PIN?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com