FANDOM


  • Whether already created, or if it can be made may I know how I could use a bot (currently has these) using JS to convert the .jpg Images in image galleries to .png format? They are already in one area so can be done gallery by gallery. There is a working method using a regular bot program, which would require:

    1. An option for the user to input the list of images to convert (or fetching it via the API according to certain parameters, like getting all images of a certain format).
    2. Afterwards, the script gets the list of all pages each image is included in.
    3. This is the trickiest part: the script downloads each image and passes it through a third-party utility that converts it and returns a copy of the desired format. You'd have to look for a JavaScript utility for image conversion. You'd probably have to experiment with a few to see which is better for your purposes, which has the best quality/size/conversion time ratio, and setting some timeouts to avoid being blocked by Wikia if you happen to download too many files too fast. If you're working with a large number of images, an utility that runs on the cloud rather than on the user's browser may be preferable for bandwidth and memory reasons.
    4. The script uploads the converted image to the wiki and copies its file information.
    5. It replaces the file in all pages that were using the old one.
    6. Finally, it deletes the old image.

    Figured find and replace could be used to input the .jpg images (extra handy if it could detect them and add rather then adding manually, but anything that works is already better than perfect). Adding images to categories already updates them across the pages for point 2. So whatever does that can be used for the image converting.

    3. An actual .jpg to .png converter is what is needed. Does Fandom have it’s own script prepared or can this part of the bot program be linked with good external ones? If the best ones are known please share them, converting twenty at a time gradually is nice and all, but nicer is always… nicer! The same timer used when images are being added to categories could be used here to prevent a too rapid fire upload.

    4. If the images are not already uploaded if the conversion does not occur there on the wiki, then all I can suggest is linking with a wikis multi uploader. Preferably a script however long to ensure the huge amount of images can be added, and minimising the risk it could be cancelled or something.

    Point 5. Would need maybe an extension of find and replace if this is all to be an automatic process meant to flow uninterrupted.

    Point 6. Is an excellent addition and great idea to include all into one. If it does prove too much to have all in one this could be left. Mass delete could simply be done after the process to remove the previous .jpg images, whichever works best.

    Rather than download each and every image (there are a ton, possibly literally) converting, re-uploading… to use a bot to do it all on the wiki, and much faster would be a best thing ever, more so for creating the JS addition of this amazing feature.

    Do hope this use a JS bot to convert .jpg images to .png format on wikis can be made!

      Loading editor
    • Replying in response to this. What do you expect to achieve by converting images from JPG to PNG? Conversions between two file formats are indeed possible, but if you expect your files to have better quality after being converted to PNG that unfortunately won't work. Once the image quality has been reduced, converting between file formats can only make it worse, in my experience.

        Loading editor
    • Thank you, with this, .png images may be better when images are viewed as thumbnails, when they are altered in size depending on what screen (like a phone one) they are viewed on. Also since it's a wiki people are welcome to the images where they can adapt as they like, so if they are in the best format that does not decrease their quality when their size is changed, all the better.

      Most importantly for the Bloody Blades images is that the .jpg images have an added background to fill out the bottom left and top right corners of the square. The altered .png files have removed this background so the images appear as they would in the game. Just a more factually accurate image rather than an altered one with something added.

      Is this helpful for the process? That only works on PCs and may be for downloaded photos, but the best case is to convert the Bloody Blades images that are already uploaded onto the wiki.

        Loading editor
    • So, do you have access to original quality PNG files and, if not, how are you converting the JPG files to PNG at the moment? Because I don't think JPG converters would just remove the background by themselves.

        Loading editor
    • Other contributors are uploading the files and presumably manually converting, hence why I felt if a bot could save the time best use that. Converting wordmark images to .png also removes a background, but in any case since .png files don't become pixelated when changed in size probably best if they were all converted to .png format.

        Loading editor
    • If the only action to be done on an image was converting it to PNG, you would have the option of:

      • Using a batch downloader to download the images you need converted (one probably exists somewhere)
      • Using an image batch converter to convert the images from one format to another (there seem to be many available online)
      • Using a batch uploader to upload the converted images (for example, Wiki-Up)
      • Using a batch delete tool to delete the old images (for example, AjaxBatchDelete)

      However, if you intend to remove the backgrounds of these images alongside converting them, that might be a trickier job. How would the converter know what exactly is the background? If it just turns a specified color transparent, how are you sure the same color doesn't appear in the actual image?

        Loading editor
    • Are there JS scripts that can achieve the same outcome? Especially for mass uploading images, need a much faster way of doing that.

      KockaAdmiralac wrote:

      However, if you intend to remove the backgrounds of these images alongside converting them, that might be a trickier job. How would the converter know what exactly is the background? If it just turns a specified color transparent, how are you sure the same color doesn't appear in the actual image?

      If they are converted on the wiki and the backgrounds aren't removed, can simply re-upload over them so that is covered.

        Loading editor
    • S3r0-Ph1i wrote: Are there JS scripts that can achieve the same outcome? Especially for mass uploading images, need a much faster way of doing that.

      There aren't any scripts for batch image conversion on Dev, and I don't really think there would need to be considering there are many other online and offline tools for it. As for uploading images, I don't think an offline tool could be any slower than a Dev script in that.

        Loading editor
    • KockaAdmiralac wrote:

      There aren't any scripts for batch image conversion on Dev, and I don't really think there would need to be considering there are many other online and offline tools for it. 

      Would these work for users who don't have computers, like those using tablets or MacBooks? The other need for a JS method is to keep everything here on Fandom - other sites are prone to suddenly closing down, for fun, apparently. Same with the mass upload of images, if there is a JS way to do that, and a way that works for Fandom rather than being reliant on other sites that would be best.

        Loading editor
    • S3r0-Ph1i wrote: Would these work for users who don't have computers, like those using tablets or MacBooks? The other need for a JS method is to keep everything here on Fandom - other sites are prone to suddenly closing down, for fun, apparently.

      The thing is that an action of batch-converting images is not really something mobile devices are expected to do. If you're using an offline tool you would be very little relying on a site.

      S3r0-Ph1i wrote: Same with the mass upload of images, if there is a JS way to do that, and a way that works for Fandom rather than being reliant on other sites that would be best.

      There's MultiUpload.

        Loading editor
    • Would the offline tools work on macs, if not could JS work?

      Thank you for pointing out the MultiUpload, that's all added and will be so handy!

        Loading editor
    • Some of the most popular tools I've noticed when Googling for "image batch conversion" seem to be cross-platform, so yeah, some should work.

        Loading editor
    • A FANDOM user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message
Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+