nbconvert markdown not searching predefined images
Question: I was wondering why ipython nbconvert --to markdown not searching the image in
directory first.

If i do this in my tes.ipynb:

    
    
    from Ipython.display import Image
    Image('tes_files/1.jpg')
    

then if i execute command

    
    
    ipython nbconvert tes.ipynb --to markdown --stdout
    

what i will get the output is

    
    
    from IPython.display import Image
    Image('tes_files/1.jpg')
    ![jpeg](tes_files/tes_0_0.jpeg)
    

Why nbconvert not searching for the path specified by the path first,

then if it doesn't exist, generate a new one?

I know maybe there's some idea that we can import image from all directory and
with nbconvert, markdown just gathering it into one folder.

Is there another option command? Do i have to create a new profile?

## UPDATE:

Suppose I have set the url path for the image folders:

> IMG_FOLDERS = '../galleries/tes_files'

and set the url path to that directory. At some point, I create a plot. Then
when I execute nbconvert, it just create a new folder 'name'_files, same dir
as the ipynb, and create a new image based on the plot inside it. How to tell
the nbconvert not to create a new directory, but instead, use IMG_FOLDERS?

Thanks


Answer: The issue here, is that the IPython `Image` class embeds the image data into
the notebook if you use it like you did in your example. Embedded images are
extracted by a preprocessor from the notebook and finally included in the
markdown, latex, etc. document during the conversion.  
So what you are looking for is a way to link an image to the notebook, which
is still possible with the `Image` class. If you check the documentation for
the `Image` class (IPython 2.3) you will find:

    
    
    Init definition: Image(self, data=None, url=None, filename=None, format=u'png', embed=None, width=None, height=None, retina=False)
    
    ...
    
    Parameters
    ----------
    data : unicode, str or bytes
        The raw image data or a URL or filename to load the data from.
        This always results in embedded image data.
    url : unicode
        A URL to download the data from. If you specify `url=`,
        the image data will not be embedded unless you also specify `embed=True`.
    filename : unicode
        Path to a local file to load the data from.
        Images from a file are always embedded.
    

Hence, to get the image not embedded but rather linked, you have to use the
`url` argument like:

    
    
    Image(url='tes_files/1.jpg')
    

There, is also an `embed` argument but this doesn't seem to work with the
filename argument.

