Quantcast

_import

Specifies an image to edit.

Remarks

Use the _import parameter to specify the image to load for editing. This parameter can be used in three different ways:

  1. You can pass in a URL which points to the image you'd like to load.
  2. You can pass in the name of a multipart form field which contains a URL which points to the image (or gallery) you'd like to load.
  3. You can pass in the name of a multipart form field which contains the image data you'd like to edit.

When giving Picnik an URL which is embedded inside another URL, be sure to encode it first (such as with Javascript's encodeURIComponent or PHP's rawurlencode). Attempting to load malformed URLs, non-existent URLs, or non-image files will result in an error dialog being shown to the user.

When using multipart form fields, the form's action attribute should be set to "POST" and the form's enctype attribute should be set to "multipart/form-data". Here's an example of what your HTTP POST might look like:

POST http://www.picnik.com/service/
Content-Length: <some number>
Content-Type: multipart/form-data; boundary=+-+FORM+-+

--+-+FORM+-+
Content-Disposition: form-data; name="_apikey"

12345678
--+-+FORM+-+
Content-Disposition: form-data; name="_import"
Content-Type: image/jpeg

<jpeg data goes here>
--+-+FORM+-+--

Note that the user will still be able to use Picnik's Photos tab to load in other photos from any of the sources which Picnik supports. See the _exclude parameter for more information about customizing the Picnik interface.

See Also

_export, _page

Samples

1. Passing an image URL directly in the _import parameter (via HTTP GET)


Load this image into Picnik!

http://www.picnik.com/service/?_apikey=YourApiKey&_import=http%3A//www.picnik.com/graphics/api/api_sample_2.jpg

The _import parameter is set to the encoded form of the URL of the image we'd like to load — in this case, a lovely chive flower.

2. Passing an image URL directly in the _import parameter (via HTTP POST)

Enter the URL of an image:

<form action="http://www.picnik.com/service/" method="post" enctype='multipart/form-data'>
	Enter the URL of an image:</br>
	<input type="text" name="_import" size="40" value="http://www.picnik.com/graphics/api/api_sample_3.jpg"/><br/>
	<input type="submit" value="Edit this image"/>
	<input type="hidden" name="_apikey" value="YourApiKey" />
</form>

In this example the _import form field is set to the URL of the image we want to load.

3. Posting a URL in a field other than _import

Enter the URL of an image:

<form action="http://www.picnik.com/service/" method="post" enctype='multipart/form-data'>
	Enter the URL of an image:</br>
	<input type="hidden" name="_import" value="image_url"/>
	<input type="text" name="image_url" size="40" value="http://www.picnik.com/graphics/api/api_sample_3.jpg"/><br/>
	<input type="submit" value="Edit this image"/>
	<input type="hidden" name="_apikey" value="YourApiKey" />
</form>

In this example the _import parameter is set to image_url, which is the name assigned to the form's text field. Picnik will look at the value of the _import field, recognize that it is not a URL, and then look for a field with the given name ("image_url", in this case). Finally, the URL that is stored in the image_url parameter is loaded.

4. Posting image data with a multipart form field


<form method="post" action="http://www.picnik.com/service/" enctype='multipart/form-data'>
	<input type="hidden" name="_import" value="image_file" />
	<input type="file" name="image_file" size="30" ><br/>
	<input type="submit" value="Upload this image"/>
	<input type="hidden" name="_apikey" value="YourApiKey" />
</form>

The _import parameter is set to image_url which is the name assigned to the form's text field. We also set the form's method attribute to "post". Note that you should never put the image data itself in the _import parameter — always put it in a separate form field and then send the name of that form field via the _import parameter.