Created
February 25, 2022 01:43
-
-
Save flashwave/256e66040a2f2367b435bd023a40c008 to your computer and use it in GitHub Desktop.
utilities used to whip ai images into shape for avatars, might need them again someday idk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
printf('[%s] Collecting...%s', date('H:i:s'), PHP_EOL); | |
$pngs = glob('tadne_png/*.png'); | |
printf('[%s] Starting...%s', date('H:i:s'), PHP_EOL); | |
foreach($pngs as $png) { | |
printf('[%s] %s%s', date('H:i:s'), $png, PHP_EOL); | |
$jpg = str_replace('.png', '.jpg', str_replace('_png', '', $png)); | |
$imagick = new Imagick($png); | |
$imagick->setImageFormat('jpeg'); | |
$imagick->setCompression(Imagick::COMPRESSION_JPEG); | |
$imagick->setCompressionQuality(90); | |
$imagick->writeImage($jpg); | |
$imagick->destroy(); | |
$hash = hash_file('sha1', $jpg); | |
rename($jpg, 'tadne/' . $hash . '.jpg'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
for($i = 0; $i < 100000; ++$i) { | |
$cat = file_get_contents('https://thiscatdoesnotexist.com/'); | |
$catPath = 'tcdna' . DIRECTORY_SEPARATOR . hash('sha1', $cat) . '.jpg'; | |
if(is_file($catPath)) { | |
printf('[%s] %s exists...%s', date('H:i:s'), $catPath, PHP_EOL); | |
sleep(1); | |
continue; | |
} | |
printf('[%s] Saving %s...%s', date('H:i:s'), $catPath, PHP_EOL); | |
file_put_contents($catPath, $cat); | |
sleep(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment