Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
File Repository
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Operations
Operations
Incidents
Environments
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
File Repository
Commits
76201839
Commit
76201839
authored
May 20, 2019
by
Viacheslav Pavlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved generating of thumbnails
parent
c9d5e0cc
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
file-repository-core/src/main/java/org/genesys/filerepository/service/impl/ImageGalleryServiceImpl.java
.../filerepository/service/impl/ImageGalleryServiceImpl.java
+8
-5
No files found.
file-repository-core/src/main/java/org/genesys/filerepository/service/impl/ImageGalleryServiceImpl.java
View file @
76201839
...
...
@@ -19,6 +19,7 @@ package org.genesys.filerepository.service.impl;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.Arrays
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
...
...
@@ -253,9 +254,9 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
imageGallery2
.
getImages
().
forEach
(
repositoryImage
->
{
try
{
final
byte
[][]
cache
=
new
byte
[
1
][];
for
(
int
thumbSize:
thumbnailSizes
)
{
ensureThumbnail
(
thumbSize
,
thumbSize
,
repositoryImage
,
()
->
{
for
(
int
i
=
thumbnailSizes
.
length
-
1
;
i
>=
0
;
i
--
)
{
cache
[
0
]
=
ensureThumbnail
(
thumbnailSizes
[
i
],
thumbnailSizes
[
i
]
,
repositoryImage
,
()
->
{
if
(
cache
[
0
]
!=
null
)
{
LOG
.
debug
(
"Using cached image bytes for {}"
,
repositoryImage
.
getStoragePath
());
return
cache
[
0
];
...
...
@@ -318,7 +319,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
* @throws IOException Signals that an I/O exception has occurred.
* @throws InvalidRepositoryPathException if path is messed up
*/
private
void
ensureThumbnail
(
final
Integer
width
,
final
Integer
height
,
final
RepositoryImage
repositoryImage
,
final
IImageBytesProvider
loader
)
throws
IOException
,
InvalidRepositoryPathException
{
private
byte
[]
ensureThumbnail
(
final
Integer
width
,
final
Integer
height
,
final
RepositoryImage
repositoryImage
,
final
IImageBytesProvider
loader
)
throws
IOException
,
InvalidRepositoryPathException
{
final
String
filename
=
getThumbnailFilename
(
width
,
height
,
repositoryImage
.
getUuid
());
if
(!
bytesStorageService
.
exists
(
getFullThumbnailsPath
(
repositoryImage
).
resolve
(
filename
)))
{
...
...
@@ -331,11 +332,12 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
LOG
.
debug
(
"Persisting new thumbnail width={} height={} for image={}"
,
width
,
height
,
repositoryImage
.
getUuid
());
bytesStorageService
.
upsert
(
getFullThumbnailsPath
(
repositoryImage
).
resolve
(
filename
),
bytesPng
);
return
bytesPng
;
}
catch
(
NullPointerException
e
)
{
LOG
.
warn
(
"Error generating thumbnail: {}"
,
e
.
getMessage
());
}
}
return
null
;
}
/**
...
...
@@ -400,6 +402,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
}
public
void
setThumbnailSizes
(
int
[]
thumbnailSizes
)
{
Arrays
.
sort
(
thumbnailSizes
);
this
.
thumbnailSizes
=
thumbnailSizes
;
}
...
...
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