Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Briar Desktop
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
Briar Desktop
Commits
3a7fa499
Commit
3a7fa499
authored
3 years ago
by
Sebastian
Committed by
Sebastian
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add two tests for image compression, one failing deliberately atm
parent
30288ef0
No related branches found
No related tags found
1 merge request
!123
Resolve "Compressing large images fails"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/kotlin/org/briarproject/briar/desktop/attachment/media/ImageCompressorTest.kt
+68
-0
68 additions, 0 deletions
...ect/briar/desktop/attachment/media/ImageCompressorTest.kt
with
68 additions
and
0 deletions
src/test/kotlin/org/briarproject/briar/desktop/attachment/media/ImageCompressorTest.kt
0 → 100644
+
68
−
0
View file @
3a7fa499
/*
* Briar Desktop
* Copyright (C) 2021-2022 The Briar Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org.briarproject.briar.desktop.attachment.media
import
java.net.URL
import
javax.imageio.ImageIO
import
kotlin.test.Test
class
ImageCompressorTest
{
private
val
compressor
=
ImageCompressorImpl
()
@Test
fun
`can
compress
voronoi
image`
()
{
// load image
val
input
=
Thread
.
currentThread
().
contextClassLoader
.
getResourceAsStream
(
"images/voronoi1.png"
)
val
image
=
input
.
use
{
ImageIO
.
read
(
input
)
}
println
(
"image size: ${image.width}x${image.height}"
)
// compress image
val
compressed
=
compressor
.
compressImage
(
image
)
// reload compressed image
val
reloaded
=
compressed
.
use
{
ImageIO
.
read
(
compressed
)
}
println
(
"image size: ${reloaded.width}x${reloaded.height}"
)
}
@Test
fun
`can
compress
quasar`
()
{
// load image
val
url
=
"https://upload.wikimedia.org/wikipedia/commons/3/38/Artist%27s_rendering_ULAS_J1120%2B0641.jpg"
val
input
=
URL
(
url
).
openStream
()
val
image
=
input
.
use
{
ImageIO
.
read
(
input
)
}
println
(
"image size: ${image.width}x${image.height}"
)
// compress image
val
compressed
=
compressor
.
compressImage
(
image
)
// reload compressed image
val
reloaded
=
compressed
.
use
{
ImageIO
.
read
(
compressed
)
}
println
(
"image size: ${reloaded.width}x${reloaded.height}"
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment