# ComicConverter Powershell Module

By
,
Powershell
,
Modules
Published 2022-07-16

# Comics are not just for kids 🚸

Get ComicConverter
https://www.powershellgallery.com/packages/ComicConverter/1.0.1

Well you may have guessed by the pictures I posted I really 😍 love reading comic books. It's sad but true 😁 and now that is over and done with lets look at a comic that is a great bedtime read for your kids 😲

# Nuget Package 📦

Again off I went to nuget.org to see what goodies could be made into awesome Powershell modules. See when building something for the Powershell gallery you kind of have to see if it has been done before, and if it has, does that mean it will be worth while? So I pretty much know all my Universal Dashboard modules were unique so that's cool, and thankfully for me, it doesn't seem there are many other comic fans out there, but I did find

So at least I had something to work with. Sure enough checking the Powershell gallery yeilded zero results. Off I went constructing this .CS file to include every possible conversion method this package offered

using System;
using System.Management.Automation;
using ComicConverter;
using PdfSharpCore;
using SharpCompress;
namespace PDFcomics
{
    [Cmdlet(VerbsData.ConvertFrom, "PDF2CBZ")]
    public class ComicCon : PSCmdlet
    {
        [Parameter(Mandatory = true)]
        public string Path { get; set; }
        [Parameter(Mandatory = true)]
        public string OutPath { get; set; }
        protected override void EndProcessing()
        {

            string pdfPath = Path;
            string cbzPath = OutPath;
            Comic pdf = new Comic(pdfPath);
            pdf.Convert(cbzPath, ComicFormat.CBZ);
            WriteObject("Completed Process");
        }
    }
}
namespace CBRcomics
{
    [Cmdlet(VerbsData.ConvertFrom, "CBR2PDF")]
    public class ComicCon : PSCmdlet
    {
        [Parameter(Mandatory = true)]
        public string Path { get; set; }
        [Parameter(Mandatory = true)]
        public string OutPath { get; set; }
        protected override void EndProcessing()
        {

            string cbrPath = Path;
            string pdfPath = OutPath;
            Comic comic = new Comic(cbrPath);
            comic.Convert(pdfPath, ComicFormat.PDF);
            WriteObject("Completed Process");
        }
    }
}
namespace CBRimgs
{
    [Cmdlet(VerbsData.ConvertFrom, "CBR2Images")]
    public class ComicCon : PSCmdlet
    {
        [Parameter(Mandatory = true)]
        public string[] ImagePaths { get; set; }
        [Parameter(Mandatory = true)]
        public string ComicName { get; set; }
        protected override void EndProcessing()
        {
            string[] imagesPaths = { };
            string comicName = ComicName;
            ComicBuilder.CreateCBZ(imagesPaths, comicName);
            WriteObject("Completed Process");
        }
    }
}


namespace imgsCBR
{
[Cmdlet(VerbsData.ConvertFrom, "Images2CBR")]
    public class ComicCon : PSCmdlet
    {
        [Parameter(Mandatory = true)]
        public string FolderPathForImages { get; set; }
        [Parameter(Mandatory = true)]
        public string ComicPath { get; set; }
        protected override void EndProcessing()
        {
            string folder = FolderPathForImages;
            string comic = ComicPath;

            ImageExtractors.UnRar(comic, folder);
            WriteObject("Completed Process");
        }
    }
}

I know this is probably not the most effective use of C# to get the job done, but it all works, which in my book is a win.

# Powershell Gallery 😍

After doing some tests on various comics I own I was able to verify that this all works, but sadly is probably not that useful to most of the community. On the plus side this is a world exclusive first comic book module to the Powershell gallery

Making dreams come true
Making dreams come true