Closed zartan9 closed 3 years ago
Hi @zartan9!
Thank you very much for asking this question. Let us assume that your JPEG files are contained in the current working directory and you wish to have them all converted into KLA format. You may want to try executing the following recipe (also described in more details below):
$ git clone https://github.com/pawelkrol/attitude-afterimage.git
$ cd attitude-afterimage/
$ sbt publishLocal
$ vim jpegs2koalas.scala
And populate it with the following content:
import java.io.{File => JFile, FilenameFilter}
import org.c64.attitude.Afterimage.Colour.Palette
import org.c64.attitude.Afterimage.File.File
import org.c64.attitude.Afterimage.File.Import
import org.c64.attitude.Afterimage.Format.KoalaPainter
import org.c64.attitude.Afterimage.Mode
val jpegs = (new JFile(".")).listFiles(new FilenameFilter {
override def accept(f: JFile, name: String) = name.matches("^.*\\.jpg$")
}).filter(_.isFile).toList.map(_.getName)
for (jpeg <- jpegs) {
val kla = "\\.jpg$".r.replaceAllIn(jpeg, ".kla")
if (new JFile(kla).exists) {
println("Target Koala Painter file already exists: \"%s\"".format(kla))
sys.exit(1)
}
print("Converting '%s' to '%s'...".format(jpeg, kla))
val backgroundColour = 0x00
KoalaPainter(File.convert(
jpeg, Import.MultiColour(backgroundColour.toByte, Palette("default"))
).asInstanceOf[Mode.MultiColour]).save(kla)
println("OK!")
}
This script shall take care of a conversion process. Running it shall convert all JPEG files in the current working directory into KLA format.
This step is optional, however highly recommended, as it allows you to trigger the conversion process using a convenience tool that sets up Scala runtime environment.
$ vim jpegs2koalas.sh
$ chmod a+x jpegs2koalas.sh
Then populate it with the following content:
#!/bin/sh
export IVY2_CACHE=${HOME}/.ivy2/cache
export IVY2_LOCAL=${HOME}/.ivy2/local
export AFTERIMAGE=${IVY2_LOCAL}/org.c64.attitude/afterimage/0.07/jars/afterimage.jar
export IMAGEJ=${IVY2_CACHE}/gov.nih.imagej/imagej/jars/imagej-1.47.jar
export JSON4S=${IVY2_CACHE}/org.json4s/json4s-ast_2.13/jars/json4s-ast_2.13-3.6.6.jar:${IVY2_CACHE}/org.json4s/json4s-core_2.13/jars/json4s-core_2.13-3.6.6.jar:${IVY2_CACHE}/org.json4s/json4s-native_2.13/jars/json4s-native_2.13-3.6.6.jar
export SCALA=/opt/scala/scala-2.13.3/bin/scala
export SCALA_CLASSPATH=${AFTERIMAGE}:${IMAGEJ}:${JSON4S}
${SCALA} -classpath ${SCALA_CLASSPATH} jpegs2koalas.scala
Now everything becomes as simple as running the following command:
$ ./jpegs2koalas.sh
Please do feel free to adjust the above recipe according to your specific needs.
Hope that helps!
wow thanks for quick reply. Seems complex as Im afraid im not good a scripting, but i would like alot of jpgs converted. could you uploading working example (Where i just switch out the jpgs/is there a limit?) .. Also im willing to donate too if you have a paypal address. Thanks.
I do understand it may seem discouraging if you are not familiar with using the command line. I think it would be the best solution if I simply create an uncomplicated GUI utility that wraps this conversion functionality: a simple file selector letting you choose a batch of JPEG files to convert, and a button to click in order to commence the process. In fact I may have some spare time over the coming weekend just to code it.
Please do not worry about donating. You will make a better use of your money if you give it to some charity instead. They will surely put it to good use.
wow great! that would be superb!!! I grew up with c64 and want to add kla images now for idea i have! ok great yes i will put money to other helpful purpose thanks!
Hi @zartan9!
I have just released v0.01 of jpg2kla, a batch converter of multiple JPEG files into KoalaPainter format wrapped by a simple graphical user interface. You can download an executable JAR from the Releases page.
I hope you will find this little program useful. I am looking forward to your idea taking shape. Good luck with your project!
thanks happy new year!!
-----Original Message----- From: Pawel Krol notifications@github.com To: pawelkrol/attitude-afterimage attitude-afterimage@noreply.github.com Cc: zartan9 zartan917@aol.com; Mention mention@noreply.github.com Sent: Fri, Jan 1, 2021 3:42 pm Subject: Re: [pawelkrol/attitude-afterimage] convert alot (#2)
Hi @zartan9!I have just released v0.01 of jpg2kla, a batch converter of multiple JPEG files into KoalaPainter format wrapped by a simple graphical user interface. You can download an executable JAR from the Releases page.I hope you will find this little program useful. I am looking forward to your idea taking shape. Good luck with your project!— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
hi i am a graphic designer but would like to convert alot of jpgs to .kla at once (to have in c64 slideshow)..im not sure how to do this or set up standalone method if you can point me to a link with working example that would be great thanks.