Skip to content

Commit

Permalink
Fix various .png images (#2574)
Browse files Browse the repository at this point in the history
* convert to png

* update

* Improve images

* update

* update

* More images

* update checked

* Fix more images

* update images

* Update checked

* Updates

* updates

* updates
  • Loading branch information
Koenkk authored Feb 15, 2024
1 parent a71dc78 commit 63d092a
Show file tree
Hide file tree
Showing 2,616 changed files with 19 additions and 21 deletions.
38 changes: 18 additions & 20 deletions docgen/missing_device_images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { imageBaseDir } from "./constants";
import * as path from "path";
import * as fs from "fs";
import * as gis from 'async-g-i-s';
import * as httpsClient from 'https';
import * as httpClient from 'http';
import * as easyimage from 'easyimage';
import {execSync} from 'child_process';

Expand All @@ -24,13 +22,10 @@ export async function getMissing(): Promise<{image: string, model: string, vendo
}

export async function downloadImage(url: string, path: string) {
const client = url.startsWith('https') ? httpsClient : httpClient;
return new Promise<void>((r) => {
client.get(url, (res) => {
res.pipe(fs.createWriteStream(path));
r();
});
});
execSync(`curl ${url} -o ${path}`);
if (!fs.existsSync(path)) {
throw new Error('failed');
}
}

export async function ensurePngWithoutBackground(imagePath: string) {
Expand All @@ -40,9 +35,7 @@ export async function ensurePngWithoutBackground(imagePath: string) {
fs.rmSync(imagePath);
imagePath = imagePathPng;
}
const imagePathBackground = `${imagePath}.background.png`
fs.renameSync(imagePath, imagePathBackground);
execSync(`rembg i ${imagePathBackground} ${imagePath}`);
// execSync(`transparent-background --source ${imagePath} --dest ${path.parse(imagePath).dir}`);
return imagePath;
}

Expand All @@ -57,26 +50,27 @@ export async function downloadMissing() {
const query = `${definition.model} ${definition.vendor}`;
console.log(`Querying '${query}'`);
// @ts-expect-error
const images: {url: string}[] = (await gis(`${definition.model} ${definition.vendor}`)).slice(0, 5);
const images: {url: string}[] = (await gis(`${definition.model} ${definition.vendor}`))
.filter((r) => r.url.endsWith('.webp') || r.url.endsWith('.jpg') || r.url.endsWith('.jpeg') || r.url.endsWith('.png')).slice(0, 5);
for (const image of images) {
let imagePath = path.join(missingImagesPath, `${path.parse(path.basename(definition.image)).name}_${images.indexOf(image)}${path.extname(image.url)}`);
try {
// Download
await downloadImage(image.url, imagePath);

// Convert to png
imagePath = await ensurePngWithoutBackground(imagePath);

// Make sqaure
// Make square
const info = await easyimage.info(imagePath);
if (info.height !== info.width) {
const size = Math.max(info.height, info.width);
await easyimage.execute('convert', [imagePath, '-resize', `${size}x${size}`, '-gravity', 'center', '-extent', `${size}x${size}`, imagePath])

}

// Convert to png
imagePath = await ensurePngWithoutBackground(imagePath);
} catch (error) {
console.error(`Failed to handle '${imagePath}' (${error}), removing...`);
fs.rmSync(imagePath);
if (fs.existsSync(imagePath)) fs.rmSync(imagePath);
}
}
}
Expand All @@ -94,7 +88,11 @@ async function moveMissing() {
if (!match) throw new Error(`Failed to match '${name}'`)
const target = path.join(imageBaseDir, `${match[1]}.png`);
fs.copyFileSync(source, target);
const size = 512;
const info = await easyimage.info(target);
if (info.height !== info.width) {
throw new Error(`${file} is not a square`)
}
const size = info.height >= 512 ? 512 : 150;
await easyimage.resize({width: size, height: size, src: target, dst: target});
} catch (error) {
console.error(`Failed to handle '${file}' (${error})`)
Expand All @@ -115,4 +113,4 @@ if (require.main === module) {
throw new Error(`Unsupported option ${arg}`);
}
} )();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ If none of the existing converters fit you can add custom ones, an external conv
To make sure a picture is available for this device on the supported devices page and in the frontend:

1. Clone [zigbee2mqtt.io](https://github.com/Koenkk/zigbee2mqtt.io)
2. Add a device picture (`.jpg`, 150x150) to `public/images/devices`.
2. Add a device picture (`.png`, 512x512, transparent background) to `public/images/devices`. Use the [Adobe Express Remove Background tool](https://new.express.adobe.com/tools/remove-background) to make the background transparent.
3. ***Optional:*** Add a markdown file for your device to `docs/devices`, use the `model` property of your definition as the filename. Most of the contents of this file will be auto-generated through docgen but you can add your own notes in a notes section. Do not use h1 or h2 heading within "## Notes"-Section.
>> \<!-- Notes BEGIN --><br>
>> \## Notes<br>
Expand Down
Binary file modified public/images/devices/0140302.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/014G2461.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/020B0B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/02973.B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/03981.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/0402946.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/046677476816.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/046677551780.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/046677552343.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/046677562229.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/046677577957.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/046677578138.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/046677803087.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/064873.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/064882.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/067646.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/067694.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/067766.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/067772.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/067775-741811.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/067776A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/067776_inverted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/07001L-07005B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/07004D-07005L.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/07008L.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/devices/07042L.png
Binary file modified public/images/devices/07043M.png
Binary file modified public/images/devices/07045L.png
Binary file modified public/images/devices/07046L.png
Binary file modified public/images/devices/07047L.png
Binary file modified public/images/devices/07048L.png
Binary file modified public/images/devices/07073L.png
Binary file modified public/images/devices/07088L.png
Binary file modified public/images/devices/07089L.png
Binary file modified public/images/devices/07115L.png
Binary file modified public/images/devices/07502L.png
Binary file modified public/images/devices/07703L.png
Binary file modified public/images/devices/07732L.png
Binary file modified public/images/devices/07743L.png
Binary file modified public/images/devices/100.001.96.png
Binary file modified public/images/devices/100.075.74.png
Binary file modified public/images/devices/100.110.51.png
Binary file modified public/images/devices/100.425.90.png
Binary file modified public/images/devices/100.462.31.png
Binary file modified public/images/devices/100.491.61.png
Binary file modified public/images/devices/10011722.png
Binary file modified public/images/devices/10011723.png
Binary file modified public/images/devices/10011724.png
Binary file modified public/images/devices/10011725.png
Binary file modified public/images/devices/1001248.png
Binary file modified public/images/devices/1001923.png
Binary file modified public/images/devices/1002994.png
Binary file modified public/images/devices/1005005194831629.png
Binary file modified public/images/devices/10297665.png
Binary file modified public/images/devices/10297666.png
Binary file modified public/images/devices/10297667.png
Binary file modified public/images/devices/106-03.png
Binary file modified public/images/devices/11830304.png
Binary file modified public/images/devices/120112.png
Binary file modified public/images/devices/12031.png
Binary file modified public/images/devices/12050.png
Binary file modified public/images/devices/12126.png
Binary file modified public/images/devices/12127.png
Binary file modified public/images/devices/12242.png
Binary file modified public/images/devices/122576.png
Binary file modified public/images/devices/12501.png
Binary file modified public/images/devices/12AB.png
Binary file modified public/images/devices/1402755.png
Binary file modified public/images/devices/1402769.png
Binary file modified public/images/devices/14147206L.png
Binary file modified public/images/devices/14148906L.png
Binary file modified public/images/devices/14149505L-14149506L_1.png
Binary file modified public/images/devices/14149505L-14149506L_2.png
Binary file modified public/images/devices/14153806L.png
Binary file modified public/images/devices/14153905L.png
Binary file modified public/images/devices/14156408L.png
Binary file modified public/images/devices/14156506L.png
Binary file modified public/images/devices/14158704L.png
Binary file modified public/images/devices/14158804L.png
Binary file modified public/images/devices/141L100RC.png
Binary file modified public/images/devices/14592.0.png
Binary file modified public/images/devices/14593.png
Binary file modified public/images/devices/14594.png
Binary file modified public/images/devices/15090054.png
Binary file modified public/images/devices/151570.png
Binary file modified public/images/devices/158-01.png
Binary file modified public/images/devices/160-01.png
Binary file modified public/images/devices/1613V.png
Binary file modified public/images/devices/1740193P0.png
Binary file modified public/images/devices/1740293P0.png
Binary file modified public/images/devices/1741530P7.png
Binary file modified public/images/devices/1741730V7.png
Binary file modified public/images/devices/1741830P7.png
Binary file modified public/images/devices/1741930V7.png
Binary file modified public/images/devices/1742030P7.png
Binary file modified public/images/devices/1742330P7.png
Binary file modified public/images/devices/1742830P7.png
Binary file modified public/images/devices/1742930P7.png
Binary file modified public/images/devices/1743030P7.png
Binary file modified public/images/devices/1743130P7.png
Binary file modified public/images/devices/1743230P7.png
Binary file modified public/images/devices/1743430P7.png
Binary file modified public/images/devices/17435-30-P7.png
Binary file modified public/images/devices/17436-30-P7.png
Binary file modified public/images/devices/1743730P7.png
Binary file modified public/images/devices/1743830P7.png
Binary file modified public/images/devices/1743830V7.png
Binary file modified public/images/devices/1743930P7.png
Binary file modified public/images/devices/1744130P7.png
Binary file modified public/images/devices/1745130P7.png
Binary file modified public/images/devices/1745430P7.png
Binary file modified public/images/devices/1745530P7.png
Binary file modified public/images/devices/1745630P7.png
Binary file modified public/images/devices/1745730V7.png
Binary file modified public/images/devices/1745930P7.png
Binary file modified public/images/devices/1746130P7.png
Binary file modified public/images/devices/1746230V7.png
Binary file modified public/images/devices/1746330P7.png
Binary file modified public/images/devices/1746430P7.png
Binary file modified public/images/devices/1746447P7.png
Binary file modified public/images/devices/1746530P7.png
Binary file modified public/images/devices/1746547P7.png
Binary file modified public/images/devices/1746630P7.png
Binary file modified public/images/devices/1746630V7.png
Binary file modified public/images/devices/1746730V7.png
Binary file modified public/images/devices/199182.png
Binary file modified public/images/devices/19DZT.png
Binary file modified public/images/devices/1GNNTS.png
Binary file modified public/images/devices/200106V3.png
Binary file modified public/images/devices/200403V2-B.png
Binary file modified public/images/devices/2189-1-xx.png
Binary file modified public/images/devices/22670.png
Binary file modified public/images/devices/2430-100.png
Binary file modified public/images/devices/2435-10.png
Binary file modified public/images/devices/27087-03.png
Binary file modified public/images/devices/291.52.png
Binary file modified public/images/devices/29165.png
Binary file modified public/images/devices/2AJZ4KPDR.png
Binary file modified public/images/devices/2AJZ4KPFT.png
Binary file modified public/images/devices/2AJZ4KPKEY.png
Binary file modified public/images/devices/2CH-ZG-BOX-RELAY.png
Binary file modified public/images/devices/3004482-3137308-3137309.png
Binary file modified public/images/devices/3025CSGZ.png
Binary file modified public/images/devices/303-0136.png
Binary file modified public/images/devices/3115331PH.png
Binary file modified public/images/devices/3156105.png
Binary file modified public/images/devices/3157100.png
Binary file modified public/images/devices/316GLEDRF.png
Binary file modified public/images/devices/3200-de.png
Binary file modified public/images/devices/3200-fr.png
Binary file modified public/images/devices/3210-L.png
Binary file modified public/images/devices/3216131P5.png
Binary file modified public/images/devices/3216131P6.png
Binary file modified public/images/devices/3216231P5.png
Binary file modified public/images/devices/3216231P6.png
Binary file modified public/images/devices/3216331P5.png
Binary file modified public/images/devices/3216331P6.png
Binary file modified public/images/devices/3216431P5.png
Binary file modified public/images/devices/3216431P6.png
Binary file modified public/images/devices/322054.png
Binary file modified public/images/devices/324131092621.png
Binary file modified public/images/devices/3261030P6.png
Binary file modified public/images/devices/3261030P7.png
Binary file modified public/images/devices/3261031P6.png
Binary file modified public/images/devices/3261048P6.png
Binary file modified public/images/devices/3261330P6.png
Binary file modified public/images/devices/3261331P6.png
Binary file modified public/images/devices/3261331P7.png
Binary file modified public/images/devices/3261348P6.png
Binary file modified public/images/devices/3300-P.png
Binary file modified public/images/devices/3300-S.png
Binary file modified public/images/devices/3305-S.png
Binary file modified public/images/devices/3306431P7.png
Binary file modified public/images/devices/3308431.png
Binary file modified public/images/devices/3310-G.png
Binary file modified public/images/devices/3310-S.png
Binary file modified public/images/devices/3315-G.png
Binary file modified public/images/devices/3315-L.png
Binary file modified public/images/devices/3315-S.png
Binary file modified public/images/devices/3320-L.png
Binary file modified public/images/devices/3321-S.png
Binary file modified public/images/devices/3323-G.png
Binary file modified public/images/devices/3325-S.png
Binary file modified public/images/devices/3326-L.png
Binary file modified public/images/devices/3328-G.png
Binary file modified public/images/devices/33943-33944-33946.png
Binary file modified public/images/devices/33951-33948.png
Binary file modified public/images/devices/33952.png
Binary file modified public/images/devices/33955.png
Binary file modified public/images/devices/33957.png
Binary file modified public/images/devices/3400-D.png
Binary file modified public/images/devices/3402831P7.png
Binary file modified public/images/devices/3417511P9.png
Binary file modified public/images/devices/3417711P6.png
Binary file modified public/images/devices/3417831P6.png
Binary file modified public/images/devices/3417931P6.png
Binary file modified public/images/devices/3418131P6.png
Binary file modified public/images/devices/3418331P6.png
Binary file modified public/images/devices/3418411P6.png
Binary file modified public/images/devices/3418631P6.png
Binary file modified public/images/devices/3418931P6.png
Binary file modified public/images/devices/3420-G.png
Binary file modified public/images/devices/3435011P7.png
Binary file modified public/images/devices/3435731P7.png
Binary file modified public/images/devices/3450-L.png
Binary file modified public/images/devices/3460-L.png
Binary file modified public/images/devices/35104001.png
Binary file modified public/images/devices/35144001.png
Binary file modified public/images/devices/368308_2010.png
Binary file modified public/images/devices/37022173.png
Binary file modified public/images/devices/37022454.png
Binary file modified public/images/devices/37022463.png
Binary file modified public/images/devices/37022474.png
Binary file modified public/images/devices/37022483.png
Binary file modified public/images/devices/37022493.png
Binary file modified public/images/devices/37022714.png
Binary file modified public/images/devices/371000001.png
Binary file modified public/images/devices/371000002.png
Binary file modified public/images/devices/371232040.png
Binary file modified public/images/devices/378RT.png
Binary file modified public/images/devices/3802960.png
Binary file modified public/images/devices/3802961.png
Binary file modified public/images/devices/3802962.png
Binary file modified public/images/devices/3802963.png
Binary file modified public/images/devices/3802964.png
Binary file modified public/images/devices/3802965.png
Binary file modified public/images/devices/3802966.png
Binary file modified public/images/devices/3802967.png
Binary file modified public/images/devices/399629_2110.png
Binary file modified public/images/devices/3A12S-15.png
Binary file modified public/images/devices/3RDS17BZ.png
Binary file modified public/images/devices/3RMS16BZ.png
Binary file modified public/images/devices/3RSB015BZ.png
Binary file modified public/images/devices/3RSB22BZ.png
Binary file modified public/images/devices/3RSL011Z.png
Binary file modified public/images/devices/3RSL012Z.png
Binary file modified public/images/devices/3RSP019BZ.png
Binary file modified public/images/devices/3RSS007Z.png
Binary file modified public/images/devices/3RSS008Z.png
Binary file modified public/images/devices/3RSS009Z.png
Binary file modified public/images/devices/3RTHS0224BZ.png
Binary file modified public/images/devices/3RTHS24BZ.png
Binary file modified public/images/devices/3RVS01031Z.png
Binary file modified public/images/devices/3RWS18BZ.png
Binary file modified public/images/devices/4000116784070.png
Binary file modified public/images/devices/4023330P6.png
Binary file modified public/images/devices/4023330P7.png
Binary file modified public/images/devices/4023331P6.png
Binary file modified public/images/devices/4033930P6.png
Binary file modified public/images/devices/4033930P7.png
Binary file modified public/images/devices/4034030P6.png
Binary file modified public/images/devices/4034031P6.png
Binary file modified public/images/devices/4034031P7.png
Binary file modified public/images/devices/404000-404005-404012-404019.png
Binary file modified public/images/devices/404001.png
Binary file modified public/images/devices/404002.png
Binary file modified public/images/devices/404006-404008-404004.png
Binary file modified public/images/devices/404017.png
Binary file modified public/images/devices/404021.png
Binary file modified public/images/devices/404022-404049C.png
Binary file modified public/images/devices/404023.png
Binary file modified public/images/devices/404024.png
Binary file modified public/images/devices/404028-44435.png
Binary file modified public/images/devices/404031.png
Binary file modified public/images/devices/404036-45327-45317-45328.png
Binary file modified public/images/devices/404037-404038.png
Binary file modified public/images/devices/404049D.png
Binary file modified public/images/devices/404062.png
Binary file modified public/images/devices/404065.png
Binary file modified public/images/devices/4040B.png
Binary file modified public/images/devices/4052899926110.png
Binary file modified public/images/devices/4052899926127.png
Binary file modified public/images/devices/4052899926158.png
Binary file modified public/images/devices/4058075036147.png
Binary file modified public/images/devices/4058075036185.png
Binary file modified public/images/devices/4058075047853.png
Binary file modified public/images/devices/4058075148338.png
Binary file modified public/images/devices/4058075168572.png
Binary file modified public/images/devices/4058075173989.png
Binary file modified public/images/devices/4058075181472.png
Binary file modified public/images/devices/4058075208339.png
Binary file modified public/images/devices/4058075208353.png
Binary file modified public/images/devices/4058075208360.png
Binary file modified public/images/devices/4058075208384.png
Binary file modified public/images/devices/4058075208391.png
Binary file modified public/images/devices/4058075208414.png
Binary file modified public/images/devices/4058075208421.png
Binary file modified public/images/devices/4058075485174.png
Binary file modified public/images/devices/4058075728981.png
Binary file modified public/images/devices/4058075729001.png
Binary file modified public/images/devices/4058075729063.png
Binary file modified public/images/devices/4058075729100.png
Binary file modified public/images/devices/4058075729124.png
Binary file modified public/images/devices/4058075729148.png
Binary file modified public/images/devices/4058075729186.png
Binary file modified public/images/devices/4058075729209.png
Binary file modified public/images/devices/4058075729223.png
Binary file modified public/images/devices/4058075729247.png
Loading

0 comments on commit 63d092a

Please sign in to comment.