Converting .jpg to .ngc

  • ckuecker
  • Away
  • Junior Member
  • Junior Member
More
28 Jan 2024 21:30 #291836 by ckuecker
Converting .jpg to .ngc was created by ckuecker
Running LinuxCNC 10 on a gantry mill / engraver.

I am trying to convert a jpg file to G-code. Using the Image to G-Code document, I tried using the terminal to convert my test file.
The result:

cnc@CNC1:~/Desktop$ image-to-gcode Mickey.jpg > mickey.ngc
Traceback (most recent call last):
  File "/usr/bin/image-to-gcode", line 29, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/image-to-gcode", line 31, in <module>
    import Image
ModuleNotFoundError: No module named 'Image'

Do I need to install these modules? Where do I find them and where do they go?

Please Log in or Create an account to join the conversation.

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
28 Jan 2024 22:07 #291842 by tommylight
Replied by tommylight on topic Converting .jpg to .ngc
In a terminal:
sudo apt update
sudo apt install python3-pil
The following user(s) said Thank You: ckuecker

Please Log in or Create an account to join the conversation.

  • ckuecker
  • Away
  • Junior Member
  • Junior Member
More
30 Jan 2024 18:59 #292002 by ckuecker
Replied by ckuecker on topic Converting .jpg to .ngc
Thanks for the reply. Tried that.
New problem:
cnc@CNC1:~/Desktop$ image-to-gcode Mickey.jpg > mickey.ngc
/usr/bin/image-to-gcode:772: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
nim = numpy.fromstring(tobytes(im), dtype=numpy.uint8).reshape((h, w)).astype(numpy.float32)
Traceback (most recent call last):
File "/usr/bin/image-to-gcode", line 502, in ui
from PIL import ImageTk
ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/image-to-gcode", line 837, in <module>
main()
File "/usr/bin/image-to-gcode", line 773, in main
options = ui(im, nim, im_name)
^^^^^^^^^^^^^^^^^^^^
File "/usr/bin/image-to-gcode", line 504, in ui
import ImageTk
ModuleNotFoundError: No module named 'ImageTk'

Do I need an updated copy of image-to-gcode?

Please Log in or Create an account to join the conversation.

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
30 Jan 2024 19:43 - 30 Jan 2024 19:43 #292006 by tommylight
Replied by tommylight on topic Converting .jpg to .ngc
Probably
sudo apt install python3-imagetk
But i can not confirm on the phone.
Also, go to scorchworks website and download dmap2gcode , give it a try.
Last edit: 30 Jan 2024 19:43 by tommylight. Reason: typo
The following user(s) said Thank You: ckuecker

Please Log in or Create an account to join the conversation.

  • ckuecker
  • Away
  • Junior Member
  • Junior Member
More
30 Jan 2024 21:12 #292016 by ckuecker
Replied by ckuecker on topic Converting .jpg to .ngc
Installed python3-pil.imagetk - it looks like it's working now. Thanks!

Please Log in or Create an account to join the conversation.

  • ckuecker
  • Away
  • Junior Member
  • Junior Member
More
30 Jan 2024 21:17 #292018 by ckuecker
Replied by ckuecker on topic Converting .jpg to .ngc
Spoke too soon. The control panel comes up, but there's errors in the terminal window: Have to hit control-c to get out after clicking 'OK'

nc@CNC1:~$ image-to-gcode Mickey.jpg > mickey.ngc
/usr/bin/image-to-gcode:772: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
nim = numpy.fromstring(tobytes(im), dtype=numpy.uint8).reshape((h, w)).astype(numpy.float32)
/usr/bin/image-to-gcode:522: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use LANCZOS or Resampling.LANCZOS instead.
ui_image = im.resize((nw,nh), Image.ANTIALIAS)

Please Log in or Create an account to join the conversation.

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
30 Jan 2024 21:58 #292026 by tommylight
Replied by tommylight on topic Converting .jpg to .ngc
No idea what is wrong now, but seems to be using some deprecated stuff, probably Python has not been switched from 2.n to 3.n.
Did you try opening the image from LinuxCNC?
Images can be opened directly from LinuxCNC and a new window is presented with lots of settings, when finished it also automatically sends gcode to LinuxCNC.
The following user(s) said Thank You: ckuecker

Please Log in or Create an account to join the conversation.

  • ckuecker
  • Away
  • Junior Member
  • Junior Member
More
31 Jan 2024 18:12 #292087 by ckuecker
Replied by ckuecker on topic Converting .jpg to .ngc
Opening the image in LinuxCNC resulted in a file with over 135,000 lines of G-code. It took quite a while to crunch through.
But it appears to be a usable file for engraving the image.
Thanks for the help!
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

  • ckuecker
  • Away
  • Junior Member
  • Junior Member
More
01 Feb 2024 17:16 #292143 by ckuecker
Replied by ckuecker on topic Converting .jpg to .ngc
One remaining issue - I can't save the generated G-code. The save file option gives an error that the input file does not exist.

Please Log in or Create an account to join the conversation.

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
01 Feb 2024 17:41 #292146 by tommylight
Replied by tommylight on topic Converting .jpg to .ngc
What folder are you trying to save to?
Make sure the folder has write permissions for your user.

Please Log in or Create an account to join the conversation.

Time to create page: 0.068 seconds
Powered by Kunena Forum