MediaUtils.java
2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.cnlive.media.utils;
import com.cnlive.media.media.entity.Media;
public class MediaUtils {
private final static String MIME_TYPE_PNG = "image/png";
public final static String MIME_TYPE_JPEG = "image/jpeg";
private final static String MIME_TYPE_JPG = "image/jpg";
private final static String MIME_TYPE_BMP = "image/bmp";
private final static String MIME_TYPE_GIF = "image/gif";
private final static String MIME_TYPE_WEBP = "image/webp";
private final static String MIME_TYPE_3GP = "video/3gp";
private final static String MIME_TYPE_MP4 = "video/mp4";
private final static String MIME_TYPE_MPEG = "video/mpeg";
private final static String MIME_TYPE_AVI = "video/avi";
/**
* isGif
*
* @param mimeType
* @return
*/
public static boolean isGif(String mimeType) {
return mimeType != null && (mimeType.equals("image/gif") || mimeType.equals("image/GIF"));
}
/**
* 是否是长图
*
* @param media
* @return true 是 or false 不是
*/
public static boolean isLongImg(Media media) {
if (null != media) {
int width = media.getImgWidth();
int height = media.getImgHeight();
float newHeight = (float) (width * 3.5);
float newWidth = (float) (height * 3.5);
return ((height > newHeight) || (width > newWidth) || (width > 15 * 1000) || (height > 15 * 1000));
}
return false;
}
/**
* 是否是长图
*
* @return true 是 or false 不是
*/
public static boolean isLongImg(int width,int height) {
if (width >0&&height>0) {
float newHeight = (float) (width * 3.5);
float newWidth = (float) (height * 3.5);
return ((height > newHeight) || (width > newWidth) || (width > 15 * 1000) || (height > 15 * 1000));
}
return false;
}
// /**
// * 是否是长图
// *
// * @return true 是 or false 不是
// */
// public static boolean isLongImg(int width, int height) {
// float newHeight = (float) (width * 3.5);
// return height > newHeight;
// }
}