5 minutes on: File management - Batch Convert PNG to JPEG Using ImageMagick

Sdílet
Vložit
  • čas přidán 8. 05. 2024
  • This is a very brief 5-minute video on the basic procedure of using ImageMagick in Windows to batch convert multiple PNG images to JPEG images, with a lossy compression so as to significantly reduce the file size of the images. As such, the method shown is mostly relevant for screenshots and images of a purely referential nature, and should not be used for any directory where original artwork might be obscurely existing in any subfolder.
    Timestamps:
    0:05 Introduction to the example scenario
    0:47 Download and install ImageMagick
    1:13 Using Command Prompt and ImageMagick to batch convert images
    3:29 Repeating the same command for all subdirectories
    4:57 Deleting the original images
    Make sure that, when searching for the original images in the given directory, the scope option "All subfolders" is selected, so as not to delete less or more original images than intended.
    Links:
    imagemagick.org/
    imagemagick.org/script/downlo...
    Command Prompt commands:
    Change current directory to intended directory:
    cd C:\Users\[YOURUSERNAME]\[YOURDIRECTORY]
    Batch convert all PNG files in current directory to JPG:
    magick mogrify -format jpg -quality 50 *.png
    Batch convert all PNG files in subdirectories of current directory to JPG:
    for /r /d %a in (*) do magick mogrify -format jpg -quality 50 "%~a\*.png"
    The quality setting has a range between 0 and 100, with 100 being the highest quality.
    Disclaimer:
    This tutorial aims to increase student awareness of the versatility of the digital tools available for use within the context of the architectural education offered by KTH. As such, it might not be generally applicable, but on the other hand, if even one student is helped by it with fulfilling deliverables requirements, the purpose of this tutorial is satisfactorily achieved. There might be inaccuracies in this tutorial video - if you identify any significant one, please tell us in the comments.

Komentáře • 46

  • @alexlarkin6855
    @alexlarkin6855 Před rokem +3

    Starts at 1:20. THanks man. Great software! Thanks for including the commands in the description.

  • @Prime96
    @Prime96 Před rokem +4

    Thank you sir. Since we cannot change windows print screen format from png to jpg, the solution is to convert the enormous quantity of printscreens using this program.

    • @SanningArkitekter
      @SanningArkitekter  Před rokem +1

      Hello, and thank you! We agree that the option to change the default Windows printscreen (WINDOWS + PRINT SCREEN) format from png to jpg would be an advantageous possibility, but since that is not possible, we would like to take the opportunity to recommend an alternative workflow, which we use extensively (due to the ordinary printscreen commando capturing both our monitors, which seldom is wanted): using the Snipping tool (WINDOWS + SHIFT + S), choosing Rectangular/Window/Fullscreen snip, click(-dragging) your desired snip, clicking the pop-up in the lower right corner (in Windows 10), and CTRL + S to save the snip in the image format you want (the format you choose gets saved as default for succeeding times). Of course these sets of commands are more numerous than the simple WINDOWS + PRINT SCREEN, but we still use it, so that we have more control over what is captured, and in what format it is saved :) We wish you the best, Sofia & Alexander

  • @sneaky_tom
    @sneaky_tom Před 5 měsíci +1

    This video was very informative even though I'm trying to convert my jpg files to png! Thank you for this tutorial!

    • @SanningArkitekter
      @SanningArkitekter  Před 3 měsíci

      That is great to hear, that you succeeded with your intended goal, even if the tutorial was the other way around :) Best wishes /S&A

  • @andresperez6724
    @andresperez6724 Před 19 dny +1

    Thankyou, most helpful

  • @salvatoremorise381
    @salvatoremorise381 Před rokem +3

    you solved my problem, thanks man!

  • @EdoSetyo
    @EdoSetyo Před rokem +1

    thanks bro, much appreciated the video

  • @orpheneus77
    @orpheneus77 Před rokem +2

    thanks man! big help!

  • @kebabskiauras8851
    @kebabskiauras8851 Před rokem +1

    thank you!

  • @Lumbrax
    @Lumbrax Před 9 měsíci

    do you know if there's a way to exclude pngs that have transparency from the conversion?

    • @SanningArkitekter
      @SanningArkitekter  Před 9 měsíci +1

      Hello! Sorry, after consulting the documentation for the Mogrify command in ImageMagick, linked below, we couldn't identify any clear way to exclude PNGs with an existing alpha channel from the batch command. With the -alpha option, one can disable the alpha channel and embed the background colour into a plain RGB image, but this is effectively flattening the image, and seems the opposite of what you want to achieve (retain transparency for RGBA PNGs by not converting them to JPEG). Excuse for not being able to help - perhaps you will find some useful option in the documentation? Best wishes to you /Sofia & Alexander
      imagemagick.org/script/mogrify.php

    • @Lumbrax
      @Lumbrax Před 9 měsíci +1

      @@SanningArkitekter no problem, after asking I also went through the documentation a bit and just decided to separate them manually before the conversion. Your video still was incredibly useful to me besides that setback so thanks!

    • @SanningArkitekter
      @SanningArkitekter  Před 9 měsíci +1

      @@Lumbrax Great to hear that you solved the problem, even if it was in a manual sorting way! Sometimes, the manual labour to do something in terms of file management can feel so overwhelming, and one might really want to find an automated solution, but at least for us, we have found that sometimes, the quickest way is simply to do the manual work instead :)
      Great to hear that the tutorial was of use to you :) /S&A

    • @Lumbrax
      @Lumbrax Před 9 měsíci +1

      @@SanningArkitekter couldn't have said it better!

  • @toonhead2
    @toonhead2 Před 2 lety +2

    Great thanks

    • @SanningArkitekter
      @SanningArkitekter  Před 2 lety +1

      We're glad that it helped! Best wishes /Sofia & Alexander

    • @toonhead2
      @toonhead2 Před 2 lety +1

      @@SanningArkitekter Yes I have the portable version but this info help me a lot. Thanks again

  • @jamesbrady1930
    @jamesbrady1930 Před rokem +1

    any way to convert tga.meta to .png.meta in unity? what would the command line for that be?

    • @SanningArkitekter
      @SanningArkitekter  Před rokem

      Sadly, we do not know sufficiently in this matter to give a definitive answer. But regarding writing metadata for converted image files, the user fmw42 on StackOverflow stated (three and a half years ago) that ImageMagick cannot modify other metadata values than the Comment and Label ones, and to write other metadata to file, the recommended software to use would be ExifTool. The relevant StackOverflow thread is found here: stackoverflow.com/questions/52957956/which-imagemagic-command-can-write-image-metadata

    • @jamesbrady1930
      @jamesbrady1930 Před rokem

      @@SanningArkitekter i actually sorted it out. I found a free image conversion app, and a bulk renaming tool as well for changing the meta files from tga.meta to png.meta and works well.

    • @SanningArkitekter
      @SanningArkitekter  Před rokem

      @@jamesbrady1930 Great to hear, James! If you want to, it could be of great appreciation for anyone aiming to do the same as you if you stated here just the names of the two applications, so that it is easier to find the right way for them :)

    • @jamesbrady1930
      @jamesbrady1930 Před rokem

      I use XnConvert to convert tga to png, and Advanced renamer for changing the tga.meta to png.meta. it has methods you can use to rename the meta file properly so that unity recognizes it and points to the png for the models. worked like a charm. Xnconvert you can do it via "files", drag and drop, or add an entire folder, it will give information on the size, dimensions, and file type among other things. advanced renamer same thing too. methods I use is "remove" to remove certain letters within the chain of the name of the file, and add a new extension "png" to replace tga. viola done in masse.

    • @SanningArkitekter
      @SanningArkitekter  Před rokem +1

      @@jamesbrady1930 Wow, thank you for this treasure of information! It will surely help others in the same position as you, and for that we are grateful! All the best /S&A

  • @asonofgod7267
    @asonofgod7267 Před rokem

    Tjena. Eftersom jag tycker mig höra en svensk prata engelska så skriver jag på svenska och hoppas på det bästa. Det vore ännu mer intressant om man automatiskt kunde konvertera alla .png filer till .jpg utan att behöva köra kommandot. Visst skulle man kunna schemalägga samma kommando i task manager men det skulle inte vara effektivt att göra det på ett schema, utan istället direkt. Så fort en fil sparas i .png skall den automatiskt konverteras till .jpeg eller .jpg.
    Bör inte det gå att göra också? Tack på förhand.

    • @SanningArkitekter
      @SanningArkitekter  Před rokem

      Hej! I all uppriktighet så vet vi inte exakt hur det skulle gå till i praktiken - annat än att göra så att man man sparar filen som JPEG direkt från det bildgenererande programmet. I fallet Windows Snipping Tool så går det bra att ändra det förhandsvalda filformatet från PNG till JPEG i sparningsfönstret (det är vad vi senare gjort), men det beror så klart på program. Om du kommer på hur du skulle göra, så skriv gärna här, så andra kan ta del av din lösning :) Allt gott /Sofia & Alexander

  • @soyebravat8903
    @soyebravat8903 Před rokem

    How can I use magic mogrify on composite command and keep the original file name?

    • @SanningArkitekter
      @SanningArkitekter  Před 9 měsíci

      Having checked the documentation ( imagemagick.org/script/command-line-options.php ), we could not find a clear answer to this - did you resolve this issue? Best wishes /S&A

  • @maurimerel
    @maurimerel Před rokem

    hi there , maybe someone can help me , im stucked at trying to convert a png image into 24bits bmp image , I use the -format bmp24+ modifier , doesnt get errors but it also doesnt convert the image . Do you have any advice ?? .

    • @SanningArkitekter
      @SanningArkitekter  Před rokem +1

      We have had a problem that when we by mistake forgot to change the actual file name file type suffix for the output for the command (in our case, from .png to .jpg; in your case, relative to the workflow demonstrated here, from .png to .bmp), it successfully converted all files from PNG to JPEG (no errors in the log) but the actual file output was .png and not .jpg, so the result was of course erroneous (JPEG images in PNG containers). We are sorry that we have no idea of any specific solution to the problem that you face, but we wanted to share the experience we had, since it has similarities with regards to the non-error nature of the log (although we did a user error). We hope that you find a solution to your problem. Sincerely, Sofia & Alexander

    • @maurimerel
      @maurimerel Před rokem

      @@SanningArkitekter I found a way previous to convert to change image format with -depth modifier then , saving as bmp , now it works great!!! apparently from what i read in image magick documentation BMP is quite a hard format to play around . Hope that helps anyone .

    • @SanningArkitekter
      @SanningArkitekter  Před rokem +1

      @@maurimerel That is great to hear, and thank you for sharing the information in how you succeeded! All the best /S&A

  • @o0A7mad0o
    @o0A7mad0o Před rokem

    😍😍😍😍😍

  • @soyebravat8903
    @soyebravat8903 Před rokem

    Is it possible to produce three different variations of colour with imagemagik using the mogrify command for every png? I'm basically trying to keep the same file name while changing the colour which I can't do if done individully as you have to specify outputname so hoping to achieve through a batch method. would appreciate the help.

    • @SanningArkitekter
      @SanningArkitekter  Před rokem +2

      Hello! This is an interesting question, which we have to admit that we don't know the answer for. When it comes to our use of ImageMagick, we often consult the official documentations, specifically the pages explaining what the individual arguments/options do with the commands (these two following pages):
      imagemagick.org/script/mogrify.php
      imagemagick.org/script/command-line-options.php
      We have not encountered your specific situation before, so we don't want to state what is best to try out, but make sure to experiment in a separate folder, with all duplicates, if you by experimental mistake do something irrevocable to the files.
      Sincerely, Sofia & Alexander

    • @soyebravat8903
      @soyebravat8903 Před rokem +1

      @@SanningArkitekter thank you for your help!

  • @o0A7mad0o
    @o0A7mad0o Před 6 měsíci +1

    Thanks you saved my life 🤍, is there any fast way to resize the videoes too ?

    • @SanningArkitekter
      @SanningArkitekter  Před 3 měsíci +1

      We are very happy to hear that!
      Without guaranteeing that it works, it might be possible to use the contents of this tutorial, as well as the one linked below:
      czcams.com/video/5ZkyS2LL6ho/video.html
      What you would do then, is to first extract all frames from the video (make sure that you use "fps=X" where X is the actual frame rate of the video, if you do not wish to reduce the framerate),
      then convert all frames using the method in this tutorial,
      and then to merge all frames together again, with the same framerate as before.
      But this would only work file-per-file, one video at a time, so it is not a recommended suggestion, more of an experimental workflow that might work on an individual file basis.
      Best wishes to you,
      Sofia & Alexander