List of usage examples for com.google.common.net MediaType JPEG
MediaType JPEG
To view the source code for com.google.common.net MediaType JPEG.
Click Source Link
From source file:helper.ThumbnailGenerator.java
/** * @param ts/*from ww w .jav a 2 s.co m*/ * the actual content to create a thumbnail from * @param contentType * the MediaType for the content * @param size * acually the width * @param name * @return a thumbnail file */ public static File createThumbnail(InputStream ts, MediaType contentType, int size, String name) { File result = null; try { if (contentType.is(MediaType.JPEG)) { result = generateThumbnailFromImage(ts, size, "jpeg", name); } else if (contentType.is(MediaType.PNG)) { result = generateThumbnailFromImage(ts, size, "png", name); } else if (contentType.is(MediaType.GIF)) { result = generateThumbnailFromImage(ts, size, "gif", name); } else if (contentType.is(MediaType.PDF)) { result = generateThumbnailFromPdf(ts, size, name); } else { result = generateMimeTypeImage(contentType, size, name); } } catch (Throwable e) { play.Logger.warn("", e); result = generateThumbnailFromImage(Play.application().resourceAsStream(THUMBNAIL_EXCEPTION_PIC), size, "png", name); } return result; }
From source file:com.andrewreitz.encryptedcamera.ui.activity.CameraActivity.java
private void openCameraWithIntent() { //noinspection ConstantConditions if (cameraIntent.resolveActivity(getPackageManager()) == null) { Timber.i("No camera application found"); ErrorDialog errorDialog = ErrorDialog.newInstance(getString(R.string.error_no_camera_app), getString(R.string.error_no_camera_app_found_message)); errorDialog.setCallback(this); errorDialog.show(getFragmentManager(), "dialog_no_camera_app_error"); return;/*ww w.j a va 2 s . c om*/ } try { // create a file to save the image fileUri = externalStorageManager.getOutputMediaFileUri(MediaType.JPEG); } catch (SDCardException e) { Timber.e(e, "Error writing to sdcard"); showSdCardError(); return; } cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name startActivityForResult(cameraIntent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); }
From source file:com.mastfrog.acteur.ClasspathResourcePage.java
protected MediaType getContentType(Path path) { MediaType type = responseHeaders.getContentType(); if (type != null) { return type; }//from w w w. ja va 2 s . co m String pth = path.toString(); if (pth.endsWith("svg")) { return MediaType.SVG_UTF_8; } else if (pth.endsWith("css")) { return MediaType.CSS_UTF_8; } else if (pth.endsWith("html")) { return MediaType.HTML_UTF_8; } else if (pth.endsWith("json")) { return MediaType.JSON_UTF_8; } else if (pth.endsWith("js")) { return MediaType.JAVASCRIPT_UTF_8; } else if (pth.endsWith("gif")) { return MediaType.GIF; } else if (pth.endsWith("jpg")) { return MediaType.JPEG; } else if (pth.endsWith("png")) { return MediaType.PNG; } return null; }