Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ includes_filtered.txt
hs_err*

sample_run
.kotlin
sample_output*
sample*.jar
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ There are a few things I'm open to help with, but that I'd like to discuss first
* Investigating whether we could offer a build of libvips in another module, to make integration easier
* I'd definitely like X86 and ARM64 support for this
* It should continue to work with cutting-edge versions of Java - not becoming a blocker to users upgrading their JVM
* Refactoring the [generator](https://github.com/lopcode/vips-ffm/tree/main/generator/src/main/kotlin/vipsffm) classes
* Refactoring the [generator](https://github.com/lopcode/vips-ffm/tree/main/generator/src/main/java/vipsffm) classes
to make them a little less scrappy, and easier to reason about, without introducing too many "design patterns"

Any change must be tested, either by using unit tests, or by improving the existing [samples](README.md#samples). The
Expand Down
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repositories {
}

dependencies {
implementation("app.photofox.vips-ffm:vips-ffm-core:1.9.8")
implementation("app.photofox.vips-ffm:vips-ffm-core:1.9.9")
}
```

Expand All @@ -43,35 +43,34 @@ generated from libvips `8.18.2` (but should be safe to use with different minor

### Thumbnail sample

To get a feeling for the bindings, here's an indicative sample written in Kotlin (using the Java bindings) that:
To get a feeling for the bindings, here's an indicative sample written in Java that:
* Loads an original JPEG image from disk
* Writes a copy of it to disk
* Creates a 400px thumbnail from the original, and writes that to disk

```kotlin
import app.photofox.vipsffm.Vips
import app.photofox.vipsffm.VImage
import app.photofox.vipsffm.VipsOption
import app.photofox.vipsffm.enums.VipsAccess
```java
import app.photofox.vipsffm.Vips;
import app.photofox.vipsffm.VImage;
import app.photofox.vipsffm.VipsOption;

// ...

// Use `Vips.run` to wrap your usage of the API, and get an arena with an appropriate lifetime to use
// Usage of the API, arena, and resulting V-Objects must be done from the thread that called `Vips.run`
Vips.run { arena ->
val thumbnail = VImage.thumbnail(
arena,
"sample/src/main/resources/sample_images/rabbit.jpg",
400,
VipsOption.Boolean("auto-rotate", true) // example of an option
)
val thumbnailWidth = thumbnail.width
val thumbnailHeight = thumbnail.height
logger.info("thumbnail image size: $thumbnailWidth x $thumbnailHeight")

val outputPath = workingDirectory.resolve("rabbit_thumbnail.jpg")
thumbnail.writeToFile(outputPath.absolutePathString())
}
Vips.run(arena -> {
var thumbnail = VImage.thumbnail(
arena,
"sample/src/main/resources/sample_images/rabbit.jpg",
400,
VipsOption.Boolean("auto-rotate", true) // example of an option
);
var thumbnailWidth = thumbnail.getWidth();
var thumbnailHeight = thumbnail.getHeight();
logger.info("thumbnail image size: {} x {}", thumbnailWidth, thumbnailHeight);

var outputPath = workingDirectory.resolve("rabbit_thumbnail.jpg");
thumbnail.writeToFile(outputPath.toAbsolutePath().toString());
});

// Optionally call at the end of your program, for memory leak detection, from any thread
Vips.shutdown()
Expand All @@ -80,7 +79,7 @@ Vips.shutdown()
## Samples

Samples are included that show various usages of these bindings. They include validations, and run on GitHub Actions as
"end-to-end tests" during development. You can find them all listed [here](https://github.com/lopcode/vips-ffm/tree/main/sample/src/main/kotlin/vipsffm/sample).
"end-to-end tests" during development. You can find them all listed [here](https://github.com/lopcode/vips-ffm/tree/main/sample/src/main/java/vipsffm/sample).

To get set up to run samples (on macOS):
* `brew install vips`
Expand Down
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
plugins {
kotlin("jvm") version "2.3.21" apply false
}
}
4 changes: 2 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ tasks.withType<Javadoc> {
testing {
suites {
val test by getting(JvmTestSuite::class) {
useKotlinTest("2.1.21")
useJUnitJupiter()
}

register<JvmTestSuite>("integrationTest") {
useKotlinTest("2.1.21")
useJUnitJupiter()

dependencies {
implementation(project(":core"))
Expand Down
37 changes: 18 additions & 19 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,41 @@ <h2 id="usage-heading">Usage</h2>
for. See details in <a href="#native-library-loading">native library loading</a>.</p>
</blockquote>
<h3 id="thumbnail-sample-heading">Thumbnail sample</h3>
<p>To get a feeling for the bindings, here's an indicative sample written in Kotlin (using the Java bindings) that:</p>
<p>To get a feeling for the bindings, here's an indicative sample written in Java that:</p>
<ul>
<li>Loads an original JPEG image from disk</li>
<li>Writes a copy of it to disk</li>
<li>Creates a 400px thumbnail from the original, and writes that to disk</li>
</ul>
<pre><code class="language-kotlin">import app.photofox.vipsffm.Vips
import app.photofox.vipsffm.VImage
import app.photofox.vipsffm.VipsOption
import app.photofox.vipsffm.enums.VipsAccess
<pre><code class="language-java">import app.photofox.vipsffm.Vips;
import app.photofox.vipsffm.VImage;
import app.photofox.vipsffm.VipsOption;

// ...

// Use `Vips.run` to wrap your usage of the API, and get an arena with an appropriate lifetime to use
// Usage of the API, arena, and resulting V-Objects must be done from the thread that called `Vips.run`
Vips.run { arena -&gt;
val thumbnail = VImage.thumbnail(
arena,
&quot;sample/src/main/resources/sample_images/rabbit.jpg&quot;,
400,
VipsOption.Boolean(&quot;auto-rotate&quot;, true) // example of an option
)
val thumbnailWidth = thumbnail.width
val thumbnailHeight = thumbnail.height
logger.info(&quot;thumbnail image size: $thumbnailWidth x $thumbnailHeight&quot;)
Vips.run(arena -&gt; {
var thumbnail = VImage.thumbnail(
arena,
&quot;sample/src/main/resources/sample_images/rabbit.jpg&quot;,
400,
VipsOption.Boolean(&quot;auto-rotate&quot;, true) // example of an option
);
var thumbnailWidth = thumbnail.getWidth();
var thumbnailHeight = thumbnail.getHeight();
logger.info(&quot;thumbnail image size: {} x {}&quot;, thumbnailWidth, thumbnailHeight);

val outputPath = workingDirectory.resolve(&quot;rabbit_thumbnail.jpg&quot;)
thumbnail.writeToFile(outputPath.absolutePathString())
}
var outputPath = workingDirectory.resolve(&quot;rabbit_thumbnail.jpg&quot;);
thumbnail.writeToFile(outputPath.toAbsolutePath().toString());
});

// Optionally call at the end of your program, for memory leak detection, from any thread
Vips.shutdown()
</code></pre>
<h2 id="samples-heading">Samples</h2>
<p>Samples are included that show various usages of these bindings. They include validations, and run on GitHub Actions as
&quot;end-to-end tests&quot; during development. You can find them all listed <a href="https://github.com/lopcode/vips-ffm/tree/main/sample/src/main/kotlin/vipsffm/sample">here</a>.</p>
&quot;end-to-end tests&quot; during development. You can find them all listed <a href="https://github.com/lopcode/vips-ffm/tree/main/sample/src/main/java/vipsffm/sample">here</a>.</p>
<p>To get set up to run samples (on macOS):</p>
<ul>
<li><code>brew install vips</code></li>
Expand Down
11 changes: 5 additions & 6 deletions generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
kotlin("jvm")
java
id("com.gradleup.shadow") version "9.4.1"
application
}
Expand All @@ -17,7 +17,6 @@ dependencies {
implementation(project(":core"))
implementation(platform("org.slf4j:slf4j-bom:2.0.17"))
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.3")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.21.3")
implementation("org.apache.commons:commons-text:1.15.0")
implementation("com.palantir.javapoet:javapoet:0.15.0")
implementation("org.slf4j:slf4j-api")
Expand All @@ -26,14 +25,15 @@ dependencies {

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(23))
// the generator uses the Class-File API, which was finalised in JDK 24
languageVersion.set(JavaLanguageVersion.of(24))
}
}

testing {
suites {
val test by getting(JvmTestSuite::class) {
useKotlinTest("2.1.21")
useJUnitJupiter()
}
}
}
Expand All @@ -53,9 +53,8 @@ tasks.withType<Jar>().configureEach {
}

application {
mainClass = "vipsffm.MainKt"
mainClass = "vipsffm.Main"
applicationDefaultJvmArgs = listOf(
"--enable-preview",
"--enable-native-access=ALL-UNNAMED"
)
tasks.run.get().workingDir = rootProject.projectDir
Expand Down
Loading
Loading