Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
cfld-region-outline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cfld-backend
cfld-region-outline
Commits
afa07d7f
Commit
afa07d7f
authored
Jan 05, 2024
by
yaobaizheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片过大进行二次压缩
parent
18308d0f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
PicUtils.java
src/main/java/com/lyy/admin/common/utils/hwobs/PicUtils.java
+3
-6
No files found.
src/main/java/com/lyy/admin/common/utils/hwobs/PicUtils.java
View file @
afa07d7f
...
@@ -32,7 +32,7 @@ public class PicUtils {
...
@@ -32,7 +32,7 @@ public class PicUtils {
File
file
=
new
File
(
pc_url
);
File
file
=
new
File
(
pc_url
);
File
file1
=
new
File
(
pc_url1
);
File
file1
=
new
File
(
pc_url1
);
compressPicForScale
1
(
file
,
file1
,
800
);
compressPicForScale
(
file
,
file1
,
1024
);
}
}
...
@@ -45,7 +45,7 @@ public class PicUtils {
...
@@ -45,7 +45,7 @@ public class PicUtils {
//目标文件
//目标文件
File
file1
=
FileUtil
.
file
(
localDir1
);
File
file1
=
FileUtil
.
file
(
localDir1
);
compressPicForScale
1
(
file
,
file1
,
800
);
compressPicForScale
(
file
,
file1
,
1024
);
}
}
...
@@ -57,7 +57,7 @@ public class PicUtils {
...
@@ -57,7 +57,7 @@ public class PicUtils {
* @param desFileSize 指定图片大小,单位kb
* @param desFileSize 指定图片大小,单位kb
* @return 压缩质量后的图片字节数组
* @return 压缩质量后的图片字节数组
*/
*/
public
static
void
compressPicForScale
1
(
File
file
,
File
newFile
,
long
desFileSize
)
throws
IOException
{
public
static
void
compressPicForScale
(
File
file
,
File
newFile
,
long
desFileSize
)
throws
IOException
{
long
fileLength
=
file
.
length
();
long
fileLength
=
file
.
length
();
if
(
fileLength
<=
0
||
fileLength
<
desFileSize
*
1024
)
{
if
(
fileLength
<=
0
||
fileLength
<
desFileSize
*
1024
)
{
return
;
return
;
...
@@ -81,9 +81,6 @@ public class PicUtils {
...
@@ -81,9 +81,6 @@ public class PicUtils {
private
static
double
getAccuracy
(
long
size
)
{
private
static
double
getAccuracy
(
long
size
)
{
double
accuracy
=
1
;
double
accuracy
=
1
;
if
(
size
>=
800
&&
size
<
1024
)
{
accuracy
=
0.6
;
}
if
(
size
>=
1024
&&
size
<
1500
)
{
if
(
size
>=
1024
&&
size
<
1500
)
{
accuracy
=
0.2
;
accuracy
=
0.2
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment