-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a way to make a VBlob from some bytes (#104)
- Loading branch information
Showing
11 changed files
with
143 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
sample/src/main/kotlin/vipsffm/sample/VImageFromBytesSample.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package vipsffm.sample | ||
|
||
import app.photofox.vipsffm.VImage | ||
import app.photofox.vipsffm.VSource | ||
import vipsffm.RunnableSample | ||
import vipsffm.SampleHelper | ||
import java.lang.foreign.Arena | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import kotlin.io.path.absolutePathString | ||
|
||
object VImageFromBytesSample: RunnableSample { | ||
|
||
// note that this is generally inefficient, use a "VImage.newFrom" method if available | ||
override fun run(arena: Arena, workingDirectory: Path): Result<Unit> { | ||
val path = Path.of("sample/src/main/resources/sample_images/rabbit.jpg") | ||
val bytes = Files.readAllBytes(path) | ||
val image = VImage.newFromBytes(arena, bytes) | ||
.thumbnailImage(400) | ||
|
||
val outputPath = workingDirectory.resolve("rabbit_copy.jpg") | ||
image.writeToFile(outputPath.absolutePathString()) | ||
|
||
return SampleHelper.validate( | ||
outputPath, | ||
expectedSizeBoundsKb = 20L..100L | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters