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
Saving image as base64 encode #399
Comments
Hi @swap17, Can you please elaborate more on how the image is cropped? Is the vertical or horizontal size smaller? Moreover, can you check what is the image size you are getting from Webcam: BufferedImage bufferedImage = webcam.getImage();
System.out.println("width " + bufferedImage.getWidth());
System.out.println("height " + bufferedImage.getHeight()); I also suggest to use JPG instead of PNG (the fist one has a lot smaller size after DCT). Check this out: import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;
public class Test {
public static void main(String[] args) throws IOException {
Webcam webcam = Webcam.getDefault();
webcam.setCustomViewSizes(new Dimension[] { new Dimension(1280, 720) });
webcam.setViewSize(new Dimension(1280, 720));
webcam.open();
ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
BufferedImage bi = webcam.getImage();
ImageIO.write(bi, "JPG", baos1);
ImageIO.write(bi, "PNG", baos2);
System.out.println("JPG = " + baos1.size());
System.out.println("PNG = " + baos2.size());
System.out.println("ratio = " + (baos2.size() / baos1.size()));
}
} The output for HD 720p is:
The JPG compression is 22 times more efficient than PNG (with default compression settings). |
I'm closing this ticket. Please comment here if you think it should be reopen. |
Thanks sarox.I had used JPG and it solved the issue |
Great :) Take care! |
I am using the below mentioned code in applet for saving image in base64 encode string .On creating image from base64 encoded string the image is cropped its not showing the complete image.please suggest.
The text was updated successfully, but these errors were encountered: