News for hackers. Stuff that matters.
Re:Programming with ChatGPT by NoraCodes on Wednesday August 28, 2024 @01:49PM (#41382150)
> https://tools.simonwillison.net/image-resize-quality is a tool for dropping in an image and instantly seeing resized versions of that image at different JPEG qualities

This is also doable with one line of bash via imagemagick in any terminal that supports the Kitty or iTerm2 graphics protocols, which is most mainstream ones (iTerm2 itself, Kitty, Konsole, etc.)

I don't say this to bash your techniques but to point out that there are other methods which permit quick prototyping and easy iteration, and that LLMs are, at least in my experience, not a paradigm-shifting improvement in this vein.

Re:Programming with ChatGPT by simonw on Wednesday August 28, 2024 @01:58PM (#41382264)
Imagemagick doesn't solve this particular problem. My goal here is to process an image so I can use it on my blog. I want to find the right balance between image size and visible quality - since images on my blog have a maximum size, I can often get away with a lower quality JPEG because it well be effectively treated as a "retina" image.

But to make that decision, I need to see the images. I could run a bash script to generate those images in a bunch of different qualities and then view them with some kind of image viewer, but that's extra steps - and it involves creating a bunch of temporary files that I then need to clean up.

With the web version I can snap a screenshot with CleanShot X and then drag that screenshot straight onto the web page. I instantly see the different images, pick one that looks good to me, download that and then drag it into my S3 uploading software (Transmit).

All of that said... if I was going to prototype this with imagemagick I would 100% use an LLM for that, too. I don't remember the imagemagick flags for this kind of thing; ChatGPT and Claude know those flags already.

Re:Programming with ChatGPT by NoraCodes on Wednesday August 28, 2024 @03:32PM (#41383300)
> But to make that decision, I need to see the images. I could run a bash script to generate those images in a bunch of different qualities and then view them with some kind of image viewer, but that's extra steps - and it involves creating a bunch of temporary files that I then need to clean up.

That's not correct at all. You can, in fact, do all of these steps in a single command line program with Konsole (or iTerm2 on Mac, or Kitty - whatever terminal you're using, as long as it supports these features), imagemagick, and bash.

$ for size in $(seq 10 10 100); do; convert -resize $size% input.png output_$size.webp; timg output_$size.webp; done

timg, here, is https://github.com/hzeller/timg, but you could use anything that speaks iTerm2 or kitty. This approach generalizes easily, too; you can easily use this to vary any parameter imagemagick supports, like webp compression or posterization or dithering, and print out any parameters of the image, like size, along with the image itself.

> With the web version I can snap a screenshot with CleanShot X and then drag that screenshot straight onto the web page. I instantly see the different images, pick one that looks good to me, download that and then drag it into my S3 uploading software (Transmit).

In my workflow, I edit in Showfoto or Darktable, resize (or, in my case, more often dither and resize) as demonstrated, and then `cp` the appropriate selected image into my blog's main image folder. Hardly more difficult, and while you might not enjoy it, that's exactly my point - we can both make things we like, but you're asserting that LLMs massively changed the landscape overall, while I'm not using them at all.

I also have a script, which took about one minute to write, that cleans up the extra temporary images, so that's not much of a concern either.

Re:Programming with ChatGPT by simonw on Wednesday August 28, 2024 @03:37PM (#41383347)
How long would it take you to knock up a working imagemagick prototype?

My LLM-assisted web prototype took two prompts and less than three minutes, start to finish.

THAT’s the game changer here. I’ve spent my career building prototypes, and I’m really fast at it. With LLMs I am 5-10x faster still.

Which means I can roll way more prototypes, and I often build prototypes that I wouldn’t have built otherwise - see: https://simonwillison.net/2023/Mar/27/ai-enhanced-developmen...

Re:Programming with ChatGPT by NoraCodes on Wednesday August 28, 2024 @03:42PM (#41383412)
I really think you overestimate how hard it is to use imagemagick. Unless you're doing really deep wizardry - or editing video on the command line, but I'm almost certain the LLM will have more trouble with that, too - it's not hard. I didn't take that command line in the above command from a script, by the way; I rewrote it from memory, in about thirty seconds, because it's not hard. There might be a syntax error, but that'd be, what, another ten seconds?

I'm not asserting that LLMs aren't useful. You demonstrate successfully that, to you, they are. I'm asserting that they're not orders of magnitude more useful than powerful, composeable interfaces to the software we already have - and they are orders of magnitude more environmentally and socially destructive.

Re:Programming with ChatGPT by simonw on Wednesday August 28, 2024 @04:03PM (#41383641)
Comparing them to "powerful, composeable interfaces to the software we already have" doesn't make sense to me, because I'm using them in conjunction with that - I'm far more able to take advantage of the software we have now because LLMs mean I don't have constantly look up zsh escaping rules, or ffmpeg invocations, or how to run AppleScript from my terminal, or how to get a fetch() to work cross-domain via CORS or whatever.

It's funny you say "editing video on the command line, but I'm almost certain the LLM will have more trouble with that, too" because ffmpeg is the perfect example of software that is almost unusable for me without LLMs, but thanks to LLMs is something I solve problems with every week: https://til.simonwillison.net/macos/quicktime-capture-script

I won't disagree on the environmentally and socially destructive aspects. The question for me is if the benefits they provide compensate for the many downsides - like the fact that I can prototype 5-10x faster, while people who have never programmed before are finally able to get started on that learning curve without being put off the first time they forget a semicolon.

Will I look back in ten year's time and say "wow, the positive applications of LLMs really had nothing on the negatives, I wish this had never been invented"? I don't know. Currently I'm leaning "it's worth it".

Re:Programming with ChatGPT by leobg on Wednesday August 28, 2024 @02:17PM (#41382493)
Could you not go a step further and use gpt4o-mini’s vision to check if the text is readable? Basically, extract the text from the biggest screenshot. Then compare it to extracts from increasingly smaller versions until the text degrades / diff crosses a threshold.
Re:Programming with ChatGPT by simonw on Wednesday August 28, 2024 @02:29PM (#41382642)
I don't think GPT-4o (or any of the other vision models) "see" at a high enough resolution to help here. The differences between high and low quality images are very slight - the text almost always remains legible in the smaller images, just with slightly more JPEG artifacts that are visible.

It may be possible to train a custom machine learning model that can identify the quality I'm looking for, but honestly it's very much a human judgement thing here.

Re:Programming with ChatGPT by russfink on Wednesday August 28, 2024 @01:57PM (#41382253)
When will AI integrate with argument parsers?

ffmpeg —-ai “convert this video to NTSC output and make the audio track quieter” my input.avi

Re:Programming with ChatGPT by simonw on Wednesday August 28, 2024 @02:00PM (#41382294)
I built a tool for that back in March: https://simonwillison.net/2024/Mar/26/llm-cmd/

    llm cmd use imagemagick to convert goats.jpg into four different JPEG qualities
I ran that just now and it suggested:

    convert goats.jpg -quality 10 goats_quality_10.jpg && \
      convert goats.jpg -quality 30 goats_quality_30.jpg && \
      convert goats.jpg -quality 50 goats_quality_50.jpg && \
      convert goats.jpg -quality 90 goats_quality_90.jpg
Which, sure enough, produced me a bunch of different quality images!
Re:Programming with ChatGPT by pandeiro on Wednesday August 28, 2024 @03:14PM (#41383136)
Your tool is really cool, thanks for making it and sharing.

I notice that a lot of times, the multi-line output I get from my prompts is truncated or the model just aborts or something. The exit code is still 0 but it seems like something went wrong.

Re:Programming with ChatGPT by simonw on Wednesday August 28, 2024 @03:22PM (#41383202)
Which model / plugin are you using there?
Re:Programming with ChatGPT by pandeiro on Wednesday August 28, 2024 @03:32PM (#41383305)
I'm using Meta-Llama-3-8B-Instruct.

BTW it's a great project and I see it's gotten massive adoption on Github, with plenty of Issues to follow. Curse of success!

Thanks again.

EDIT: Created an Issue for it, probably a more appropriate place to file this ;)

https://github.com/simonw/llm/issues/561

Re:Programming with ChatGPT by throwup238 on Wednesday August 28, 2024 @03:44PM (#41383431)
aichat has shell integration scripts that allow you to write English into the command line and press Alt+E to have it replaced with a command: https://github.com/sigoden/aichat/tree/main/scripts/shell-in...

So you'd just type "use ffmpeg to convert 'my input.avi' to NTSC output and make the audio track quieter" => Alt+E => replaced with `ffmpeg -i "my input.avi" -target ntsc-dvd -af "volume=0.5" "output.mpg`