Jump to content

Recommended Posts

Hey guys, I was starting a project and I was wondering, how would I take a 1 pixel slice, say in the middle of an image and return the hex color for each pixel across? I'm thinking I need to use the function 'imagecolorat', but I'm just not sure how to go about this. Any help would be GREATLY appreciated, resources or anything that might be useful.

Link to comment
https://forums.phpfreaks.com/topic/142900-help-with-the-gd-library/
Share on other sites

look at this post.  All you have to do is strip out the outer loop and conditions and stuff.

look at this post.  All you have to do is strip out the outer loop and conditions and stuff.

 

Thanks, I appreciate it. I don't want to sound ungreatful, because the code is very very helpful to me but I'd also like, if you had available, maybe other resources to teach me how to do it because I want to code it from scratch so that I can understand what I'm doing better. Thanks  :).

Well what are you expecting, a tutorial on how to pick a specific pixel row in an image file, and loop to the end of it? I doubt you're going to find a tutorial that specific.  The post I pointed you to does exactly what you want, only more.  It just loops through all of the rows and does some condition the other guy needs, that has nothing to do with what you want.  As said, all you need to do is remove the outer for loop and use the specific row number you want, and cut out the condition, since you don't need it.  I don't think it will get any more specific for you.  There is plenty of comments in the code, and you can also go to the manual and look at each of those GD functions to read up on what all they actually do.

 

You said you don't want to sound ungrateful, but I mean come on, I'm handing something to you on a silver platter.  What more do you want?

So you want him to tell you how to do it, but you want to do it from scratch?

 

 

Well, if you want to start from the basics:

 

http://php.net/gd

 

Did I ever once say I want someone to tell me how to do it? It was really a request for a resource to teach me how to do it, I've already read through every function of the GD library. I pretty much know it's the function imagecolorat that's gonna really get me through what I'm trying to do, I'm just not 100% sure on how to use it to achieve what I want.

 

Well what are you expecting, a tutorial on how to pick a specific pixel row in an image file, and loop to the end of it? I doubt you're going to find a tutorial that specific.  The post I pointed you to does exactly what you want, only more.  It just loops through all of the rows and does some condition the other guy needs, that has nothing to do with what you want.  As said, all you need to do is remove the outer for loop and use the specific row number you want, and cut out the condition, since you don't need it.  I don't think it will get any more specific for you.  There is plenty of comments in the code, and you can also go to the manual and look at each of those GD functions to read up on what all they actually do.

 

You said you don't want to sound ungrateful, but I mean come on, I'm handing something to you on a silver platter.  What more do you want?

 

Alright then; I really appreciate it :).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.