Depending on exactly what you need, it can be a more or less trivial thing. Here is the essential idea of how you can proceed:
1- Find the items on the project.
2- Add them to a comp(if they are not in a comp);
3-Match the duration of the image layer to the audio duration.
Here is a pretty basic example:
function findItem(name, filter, items) {
var item;
var filters = (!filter) ? FootageItem : filter;
var items = items || app.project.items;
for (var i = 1, l = items.length; i <= l; i++) {
item = items;
if (name == item.name && item instanceof filter) {
return item
}
if (item instanceof FolderItem) {
findItem(name, filters, item.items);
continue
}
}
}
function matchAudioDuration(itemName, imgExtension, audioExtension){
var img, audio, comp;
img = itemName + '.' + imgExtension; //Image name
audio = itemName + '.' + audioExtension;//Audio name
img = findItem( img, FootageItem); //The mage itself
audio = findItem(audio, FootageItem); //The audio itself
comp = app.project.activeItem; //Or any comp, ie: findItem('myComp', CompItem);
img = comp.layers.add(img); //Add the image to the comp
img.outPoint = audio.duration; //Set the duration of the image layer to fit audio
comp.layers.add(audio); //Add the audio to the comp
}
matchAudioDuration('myItem', 'png', 'mp3');