Dynamically Generated Images Addon
Before I begin, special thanks to Digital and Hare over at TGL. I couldn't have done this without them! (Link to original discussion)
What this does: This addon will use Imagick (a.k.a ImageMagick) to layer multiple images, compress them into one, and display them wherever you'd like without using AJAX. This can be used for backgrounds, decors, or dynamically generated pets. (Great for breeding sites!) I recommend you read the entire tutorial and then tailor it to fit your needs rather than following along right away. -Getting the images ready- As an example, I have my pet's layers saved as separate, transparent png images. Make sure they appear on top of each other properly! Also make sure all of the images are the same size, don't crop them! This can easily be checked in any art/art editing program that allows layers (I use FireAlpaca). Then it's on to the folder structure. You can set in up in the picuploads folder. This is how mine looks: -Step 0- On x10host: Installing Imagick is easy for you. Just navigate to CPanel and find "select PHP version". Click on it and look for the "imagick" plugin (should be in the second column). Check the box, hit save, and you're done! (If you're not on x10, your host might have this too. If not, continue to the second option below) On XAMPP/Other hosts: Whether you're using a XAMPP server or a host that doesn't allow the above, follow this tutorial: Link. If not using XAMMP, make sure you search google on how to install imagick on your host before taking this route! It could be different based on your host. -Step 1- Navigate to phpMyAdmin and get some columns set up in owned_adoptables. Use consistent naming conventions! It will make your life 100% easier in the long run I promise you. For the sake of this tutorial, I'm going to use my column names and code as an example. Here are the new columns I made with the names: http://www.clipular.com/c/6503018441...AOLqimNRF4EvqI -Step 2- Navigate back to the root folder and make a new php file to hold the Imagick code. (I called mine wolfimage.php) Inside, this is how it looks: PHP Code:
We're just about done! Don't believe me? Next I went to myadoptsview.php (called denview.php for me) and used this to get the image: PHP Code:
http://www.clipular.com/c/4841643219...urpBnROg9az4lc http://www.clipular.com/c/4753780536...lzHDCOB9gvvZk8 -Finale- -Imagick and relative paths- Imagick for PHP 5.4 does not like relative paths, so absolute paths are required for it to work. I'm not sure if that's still the case with newer PHP versions. -Playing with Imagick- The markings images for my wolves are actually really messy and don't fit inside the lines. I fixed this by using COMPOSITE_DSTIN, which does it for me. (Yay, laziness! The reason the base itself doesn't completely fit in the lines is because I neglected to do so on the image itself, not because of imagick) To use your own filters, just poke around here and try them out to see which ones you like: Clicky. -Backslashes vs. Forwardslashes- If you use XAMPP/WAMPP like me, you'll have to use double backslashes. If you're operating online, then you use single forwardslashes like any other URL. -Need help tailoring?- Just let me know in the comments if things are going wrong. I can help you out with it. |
Wow, this is awesome!! :3 Thanks for doing this.
|
Interesting. Note Imagick is a PECL extension that is not available unless it is installed on the server. MysidiaHost has it since I installed Imagick extension for my server, but good chance on other webhosts like x10hosting you cannot do this. Wont be a problem if you run your VPS or Dedicated server though, you will be able to install Imagick yourself.
|
X10 (free version; paid too I'm assuming) offers it along with some other plugins, but it has to be enabled. I'm not sure how it is for other hosts though.
|
I wonder how difficult it'd be to devise a generator/designer for users to use a drop-down or such to make custom pets :0
|
Actually....
https://orig00.deviantart.net/4cc9/f...an-dbm6nln.gif I can give info on how to do this if you want. The only problem with my current method is that I can't seem to have the dropdown make the current color the "active" option after submitting. So "black" would always be at the top of the base color dropdown list for example, even if the user chose "red". It'd be great if anyone figured out a way to fix that though. |
Well okay then XD
If you could I would absolutely appreciate it! I love systems like that because you can make it easy for users to purchase custom pets (something I want to implement premium currency for lol) :smile: |
This is what I had on a page called "custompetgenerate.php". It holds the Imagick code:
PHP Code:
It isn't included here, but each user has a row generated when they register on the site; that row has default values to show a "blank" pet. PHP Code:
|
Thank you!!
So knowing how it saves in the database I think I can fix the drop-down selection problem. What needs to be done is modify the first (aka default) option to reflect what the user has listed in the database. It'll look sort of like this I think: HTML Code:
<option selected>{$selectedbase}</option> PHP Code:
And thank you again, Dinocanid!!! |
OK, finally giving this a try (feeling slightly more confident than last week, though the breeding script edits will still be offloaded to you, haha. I'm afraid to touch that stuff yet).
edit: never mind, figured out first issue. Reading that TGL thread was very helpful. Still getting a blank image though. Syntax error maybe? I removed the composite_dstin bit 'cause that command isn't needed here. PHP Code:
Linearts are in the level folder: http://griffusion.elementfx.com/picu...h/f/5/line.png Sorry for the constant questions, haha. You've been amazingly helpful lately. |
You're right on both! You need to set the iterator index on whatever layer you want to use commands/filters on. For example, you set the index to 1 and apply stuff to that, then you would set the index to 2...etc.
Wolves is the same as owned_adoptables too, I just made a custom table since I use a custom class and stuff. If it's still showing a blank image, do your image names have spaces in them? It's weird, but on some hosts they can't have any spaces (that's what I just found out about mysidiahost). Some hosts do, while others don't, so it's something to try. |
Awesome, thanks!
Every folder and image name is a single word (black, white, tan, blue, inner1 etc). The body part names match the DB columns exactly. Imagick is enabled. I'm lost. ^^' Earlier I naively thought you'd need access to the x10hosting cpanel to do anything for us, but just realised FTP could be used to poke around, to an extent. If it would help here, I can send you details for that? (and if you feel like it, maybe do the other mods while you're in there... my paypal is ready lol. I'm just not sure which tasks will require DB access. Guess I'll send you a PM in a few minutes and you can decide.) edit: oh, another thing that must be asked. How does this script work on pages with multiple creatures? Like the main myadopts page, breeding, user profiles. I'm guessing it doesn't. So we would need to save each griffin's image (or at least a thumbnail-sized version) into a folder somehow, to fetch from... or is there another way? |
You can send me FTP details and I can see what I can do ^^ (It's also waaay more secure, some people just send their login details)
You're right about it not working on pages that show multiple creatures at once, but you could save each generated image; the only thing is that I can see that taking up a whole lot of disk space in the long run. I haven't looked into saving the images with imagick specifically, but I'm sure it can be done if you're willing to go that route. |
... OK, I kept trying to send the message last night and now tonight, but it gives an error. Not the first time Mysidia forum has done this. :hmmm:
So the list is posted for you here, and I'm not sure how to securely send the FTP info. Sorry about this. ^^' |
It's fine! I just sent you an email.
|
I updated the code. Now it should work fine as an image by using:
HTML Code:
<img src='/yourfilename/{$adoptIDevariable}'> HTML Code:
<img src ='/wolfimage/{$wid}' height='auto' width='75%'> |
!! Excite !! :colonu:
Okay so I am just hoping you could help me understand this; Code:
$composed_image->setIteratorIndex(2); Then for the layer labels, is it descending from top-down? So for you example is this layer "2"? Code:
'http://wild-souls.mysidiahost.com/picuploads/wolf_images/adult/shade.png' Code:
'http://wild-souls.mysidiahost.com/picuploads/wolf_images/adult/lineart.png' Thank you, and happy holidays! |
1. Yep! So layer 2 would appear within layer 1
2. It ascends from top to down. So the first in the array is 0, the second would be layer 1, etc. In short, the items in the bottom of the array appear on top of the items in the top of the array, if that makes sense. |
Alright, that absolutely answers my questions! Thanks!
(Trying to use this to create a geno/pheno system...it's...tedious lol) |
How would I tailor the script to allow multiple different species of breedable animals?
Let's say I wanted to make a site where the user could breed snakes and lizards.. and I wanted to use the random image generator. If a user bred two snakes together, how would the script know not to put a lizard marking on the new baby snake, and only use snake images? I really love this idea, I sometimes think too hard about the logic though... |
You could use variables in the image url, so it fetches the proper species type. For example:
Quote:
PHP Code:
PHP Code:
|
Quote:
Yes thank you! this will help a lot, since I am Planning on making marking sets for babies too, and of course multiple species types. |
All times are GMT -5. The time now is 03:42 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.