Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Import png slices #358

Open
arminrosu opened this issue Mar 3, 2024 · 1 comment
Open

Feature Request: Import png slices #358

arminrosu opened this issue Mar 3, 2024 · 1 comment

Comments

@arminrosu
Copy link

Hello,

I'm trying to import voxels from CnC Tiberian Sun into Goxel, by way of PNG slices. Currently there is no import support for them.

I used ImageMagick and bash to convert the slices to Goxel text files. It's a bit of a hassle, but it works. Would be nice to have import support though.

Here's the bash script for anyone also wanting to do this:

$folder=slices_go_here
images=$(find "$folder" -type f -name "*.png" | sort)
index=0
txt=$folder".txt"
echo "Processing $txt"
rm $txt
touch $txt
for image in $images; do
  echo " $image"
  # Output of `convert` looks like:
  # 5,2: (0,0,0,0)  #00000000  none
  # 6,2: (36,16,4,255)  #241004FF  srgba(36,16,4,1)
  convert $image txt: | tail -n +2 | awk -v idx="$index" '{print  $1 " " idx " " $3 " " $4}' >>$txt

  ((index++))
done

sed -i '' 's/,/ /g' $txt
sed -i '' 's/#//g' $txt
sed -i '' 's/://g' $txt
# Remove alpha info and srgba
sed -i '' 's/FF srgba.*//g' $txt
# Remove transparent pixels, $4 above
sed -i '' '/none/d' $txt
# Lowercase
tr '[:upper:]' '[:lower:]' <$txt >temp_file && mv temp_file $txt
@guillaumechereau
Copy link
Owner

Yes, I will try to add the import for that, since we already have an export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants